Fork me on GitHub
#hugsql
<
2022-02-19
>
rgm18:02:00

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.

rgm18:02:48

I just end up throwing the maps away, and I'd like to get rid of that overhead.

curtis.summers02:02:09

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.

curtis.summers14:02:54

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.

rgm16:02:59

oh this is great. Somehow I missed that there are extra arities to the hugsql functions. You're right, though, array of arrays versus array of maps isn't much different but I'll see what I could do to get array of string.

rgm16:02:31

in the end it's probably fine for the use I'm working on right now, but this is great to know about in future.