This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-04
Channels
- # announcements (5)
- # aws (12)
- # beginners (76)
- # boot (29)
- # cider (24)
- # circleci (9)
- # clojure (64)
- # clojure-dev (27)
- # clojure-europe (3)
- # clojure-houston (1)
- # clojure-italy (33)
- # clojure-nl (19)
- # clojure-poland (1)
- # clojure-spec (6)
- # clojure-uk (20)
- # clojurescript (103)
- # clojutre (1)
- # code-reviews (60)
- # cursive (76)
- # data-science (20)
- # datomic (20)
- # duct (58)
- # figwheel-main (4)
- # fulcro (36)
- # graphql (6)
- # kaocha (4)
- # onyx (1)
- # pathom (15)
- # quil (3)
- # re-frame (15)
- # reagent (15)
- # reitit (9)
- # remote-jobs (2)
- # rewrite-clj (16)
- # ring-swagger (7)
- # shadow-cljs (132)
- # spacemacs (12)
- # sql (5)
- # vim (9)
- # xtdb (12)
- # yada (4)
I want to update a column for multiple rows in one jdbc call. This is what I tried (jdbc/update! spec :appuser {:org-id org-id} ["id in ?" user-ids])
, where user-ids is a vector of uuids. But I get the following error: Can't infer the SQL type to use for an instance of clojure.lang.PersistentVector. Use setObject() with an explicit Types value to specify the type to use
Does anyone know what could be wrong?
I found this workaround, but I guess there is a better way of doing it.
(let [where-clause-str (str "id in (" (clojure.string/join ", " (take (count user-ids) (repeat "?"))) ")")
where-clause (cons where-clause-str user-ids)
{:keys [success? processed-values]} (sql-utils/sql-update! spec logger :appuser {:org-id org-id} where-clause)]
The solution, just in case it's useful for someone: https://stackoverflow.com/questions/35513113/how-to-insert-and-update-postgres-arrays-using-yesql-in-clojure/35518713#35518713
I had to extend the clojure.java.jdbc/ISQLParameter
as shown there, and also change id in ?
to id = any(?)