Hi all, will appreciate any help with this issue 🙏 https://clojurians.slack.com/archives/C1Q164V29/p1687703215327339
What is the code that you currently have?
@shlomit.sibony I'm wondering if HoneySQL's :array syntax will help here, based on the manually constructed insert you showed that worked: https://github.com/seancorfield/honeysql/blob/develop/doc/special-syntax.md#array
(I'd point you at the better-formatted docs but http://cljdoc.org is down right now)
Somewhat related - when working with lots of similar values, I prefer to bind them as a single array parameter and not as multiple separate parameters. To do that, I have a few helpers. E.g. when I need to query some items based on their integer IDs, I use this:
(defn ids [coll]
(into-array Integer/TYPE coll))
Perhaps a similar approach can work here. Probably not with plain arrays but your own custom wrapper type that has special PG<->CLJ conversion defined for it.thanks @p-himik, I use the ->pgobject wrapper as written in https://github.com/seancorfield/next-jdbc/blob/8e68c1be61c9aa7d71d0faa373accbe2762e35c8/doc/tips-and-tricks.md#working-with-json-and-jsonb
How can I extend it to array of pg objects in prepare/SettableParameter of IPersistentVector using the method you suggested?
@p-himik that worked!!! I had to change prepare/SettableParameter from:
IPersistentVector
(set-parameter [v ^PreparedStatement s i]
(.setObject s i (->pgobject v)))
to
IPersistentVector
(set-parameter [v ^PreparedStatement s i]
(.setObject s i (into-array PGobject (mapv ->pgobject v))))
Thank you! 👑Although not mentioned in #releases this also includes the experimental formatf function for folks to play with and provide feedback on.