Just a plea, folks: please use threads to reply to questions and provide follow-up information. Also, @livingfossil was there anything confusing or that could be improved in the PostgreSQL-specific docs, that would have helped you here? https://cljdoc.org/d/com.github.seancorfield/honeysql/2.7.1310/doc/getting-started/postgresql-support
@livingfossil The Clause Reference uses raw hash maps:
user=> (sql/format {:insert-into :companies
:values [{:name "Microsoft"}]
:on-conflict {:on-constraint :name-idx}
:do-nothing true})
["INSERT INTO companies (name) VALUES (?) ON CONFLICT ON CONSTRAINT name_idx DO NOTHING" "Microsoft"]
;; empty :on-conflict combined with :on-constraint clause:
user=> (sql/format {:insert-into :companies
:values [{:name "Microsoft"}]
:on-conflict []
:on-constraint :name-idx
:do-nothing true})
["INSERT INTO companies (name) VALUES (?) ON CONFLICT ON CONSTRAINT name_idx DO NOTHING" "Microsoft"]
https://cljdoc.org/d/com.github.seancorfield/honeysql/2.7.1310/doc/getting-started/sql-clause-reference#on-conflict-on-constraint-do-nothing-do-update-set -- I guess I can add a link from the PG section to that.The only thing that I would add to the examples is a :on-conflict {:on-constraint 'foo} example. I didn’t see that syntax before looking at the tests. My issue was pretty idiosyncratic.
@livingfossil like this? (screenshot from current docs)
I had trouble specifically with the putting the nested call of on-constraint in the map format. (This could have been me just not being familiar with how honeysql treats maps as values in the map format).
Ah, and the only example is via the helpers? Gotcha. I'll create an issue and add a non-helper version of that...
Aha. Yea, this largely seems like it was operator error on my part. I should have started with the clause reference when I got stuck.