Fork me on GitHub
#honeysql
<
2022-05-10
>
dcj19:05:28

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

seancorfield20:05:49

I don't use PostgreSQL but it sounds like the answer would be "yes" to that question?

seancorfield20:05:11

Unless there's some shorthand PostgreSQL uses for that?

seancorfield20:05:52

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]}

seancorfield20:05:35

So :values [my-value-hash-map] ... :do-update-set {:fields (keys my-value-hash map)} ... Something like that?

dcj20:05:45

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! thanks3

seancorfield20:05:11

LMK if it actually works 🙂

seancorfield20:05:22

@dcj Let me know what you figure out works in the end...