honeysql

seancorfield 2025-05-21T00:39:25.160819Z

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

👍 2
seancorfield 2025-05-25T15:07:17.237509Z

@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.

jcd 2025-05-21T02:47:03.738659Z

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.

seancorfield 2025-05-21T12:28:52.522219Z

@livingfossil like this? (screenshot from current docs)

jcd 2025-05-21T12:33:28.412399Z

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).

seancorfield 2025-05-21T12:35:17.920389Z

Ah, and the only example is via the helpers? Gotcha. I'll create an issue and add a non-helper version of that...

🙏 1
jcd 2025-05-27T13:38:04.419769Z

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.

2025-05-21T12:36:08.046409Z

2025-05-25T15:11:45.281969Z