This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-19
Channels
- # announcements (1)
- # architecture (8)
- # babashka (8)
- # beginners (68)
- # biff (1)
- # calva (2)
- # clj-kondo (13)
- # cljs-dev (2)
- # clojure (71)
- # clojure-art (26)
- # clojure-europe (14)
- # clojure-nl (10)
- # clojure-uk (4)
- # clojurescript (96)
- # community-development (6)
- # conjure (1)
- # datalog (2)
- # emacs (6)
- # fulcro (20)
- # hugsql (7)
- # lsp (6)
- # nextjournal (13)
- # off-topic (7)
- # portal (1)
- # reagent (5)
- # reveal (8)
- # sci (50)
- # shadow-cljs (8)
- # spacemacs (2)
- # tools-deps (9)
- # xtdb (6)
I might be missing something in the docs, but is there a way to get back a single column SELECT as a seq of values instead of a seq of maps each with one key, value? :raw
didn't seem to do it in the next-jdbc adapter.
You can use :raw
, but you also have to consider what the underlying library is returning. The 4th argument of your hugsql-defined function takes options and sends them along to the underlying library. In clojure.java.jdbc
, you could send along {:as-arrays? true}
for a result like [["id"] [1] [2] [3]]
. I suspect there is a similar option for next.jdbc.
I think it's {:builder-fn next.jdbc.result-set/as-unqualified-lower-arrays}
per: https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.2.772/doc/migration-from-clojure-java-jdbc#rows-and-result-sets
It occurs to me that the arrays returned here aren't much better than the maps, since you still have to take the first item (columns) off and then the first of each vector. So, it's either (flatten (rest x))
for this return value, or (map :id x)
for the maps.