Fork me on GitHub
#honeysql
<
2024-02-13
>
Akiz06:02:11

Edit: I found the solution, maybe it will help somebody. on-conflict supports where clause.

(h/on-conflict :name :car :brand {:where [:not= :some-column nil]})
Good morning, I am trying to write “ON Conflict with WHERE clause” which is supported by Postgresql. Some discussion happened here so it should be possible, can somebody give me an example how to write something like this? https://clojurians.slack.com/archives/C66EM8D5H/p1601321215069100
INSERT INTO table (name, formula, car, brand)
VALUES ('abcd, '100, '8afc4b89-9738-4019-adab-d612dda6020c', 'renault')
ON CONFLICT (name, car, brand) WHERE some_column IS NULL
DO UPDATE SET name = EXCLUDED.name, formula = EXCLUDED.formula, car = EXCLUDED.car, brand = EXCLUDED.brand