This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-10
Channels
- # announcements (3)
- # babashka (16)
- # beginners (41)
- # biff (4)
- # calva (14)
- # circleci (1)
- # clj-http (24)
- # clj-kondo (9)
- # clj-on-windows (31)
- # cljs-dev (52)
- # clojure (162)
- # clojure-australia (10)
- # clojure-europe (52)
- # clojure-nl (2)
- # clojure-spec (1)
- # clojure-uk (5)
- # clojurescript (40)
- # conjure (6)
- # core-async (3)
- # cursive (5)
- # datalevin (11)
- # datomic (7)
- # emacs (12)
- # etaoin (19)
- # events (1)
- # figwheel-main (17)
- # fulcro (4)
- # graalvm (3)
- # gratitude (13)
- # honeysql (8)
- # introduce-yourself (7)
- # london-clojurians (1)
- # off-topic (9)
- # polylith (9)
- # rdf (1)
- # re-frame (21)
- # releases (5)
- # remote-jobs (4)
- # sci (28)
- # shadow-cljs (15)
- # spacemacs (2)
- # vim (4)
- # xtdb (15)
For an upsert (using Postgres) :on-conflict
I want to update every column/value specified in :values
, and I do not understand what I should specify for :do-upset-set
, can/should I just provide the same hashmap of column names and values that I used for :values
? Yes I (tried to) read https://cljdoc.org/d/seancorfield/honeysql/2.0.0-rc2/doc/getting-started/sql-clause-reference?q=do-update#on-conflict-on-constraint-do-nothing-do-update-set and https://cljdoc.org/d/seancorfield/honeysql/2.0.0-rc2/doc/getting-started/postgresql-support#upsert
I don't use PostgreSQL but it sounds like the answer would be "yes" to that question?
Unless there's some shorthand PostgreSQL uses for that?
Maybe you just need the keys
of that hash map? Based on this example in those docs:
:do-update-set {:fields [:phone :name]
:where [:= :user.active false]}
So :values [my-value-hash-map] ... :do-update-set {:fields (keys my-value-hash map)} ...
Something like that?
This seems like a good way to go, when I first read the docs I was like "I don't want to list out all the :fields
, but DUH, (keys my-value-hash-map)
is obviously the easy way to do that!
LMK if it actually works 🙂
@dcj Let me know what you figure out works in the end...