Fork me on GitHub
#sql
<
2021-01-17
>
jaihindhreddy16:01:53

For people using next.jdbc with Postgres, am I doing this right?

(next.jdbc/execute! ds
  ["select id from profiles where id = ANY(?)"
   (into-array ["id1" "id2"])])
Can I somehow do without the into-array call?

jaihindhreddy16:01:27

I got the ANY(?) trick https://cljdoc.org/d/seancorfield/next.jdbc/1.1.613/doc/getting-started/tips-tricks#postgresql, and I found I can extend next.jdbc.prepare/SettableParameter to clojure.lang.IPersistentVector to make it so that I don't have to type into-array every time, but it still happens underneath...

seancorfield17:01:26

@jaihindhreddy The PG driver needs a Java array, not a Clojure vector, so I don't think you can get away from having that somewhere in the call stack.

👍 6
emccue18:01:40

if you don't extend vectors to be interpreted as json, you can make them auto convert to arrays

emccue18:01:52

you need an array at some point in the callstack, yes

emccue18:01:39

but you can make it implicit if you really want to

👍 3