sql

All things SQL and JDBC...
jaihindhreddy 2021-01-17T16:17:53.016600Z

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?

jaihindhreddy 2021-01-17T16:21:27.018300Z

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...

seancorfield 2021-01-17T17:38:26.019500Z

@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.

👍 2
emccue 2021-01-17T18:18:40.020Z

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

emccue 2021-01-17T18:19:52.020900Z

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

emccue 2021-01-17T18:20:39.021600Z

but you can make it implicit if you really want to

👍 1