honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
benny 2020-12-30T03:13:45.271100Z

how does one update from another table for postgres? according to this https://www.postgresqltutorial.com/postgresql-update-join/ I should do update … set … from … but when i run it in honey, i get update … from which results in sql that won’t run against psql with ERROR: syntax error at or near "FROM"

(sql/format {:update :t1
             :set    {...}
             :from   [:t2]
             :join   [:t3 [:= :t2.id :t3.ref_id]]
             :where  [...]})

seancorfield 2020-12-30T03:22:07.271600Z

@benny Use :set0 instead of :set.

seancorfield 2020-12-30T03:22:42.271800Z

See https://github.com/seancorfield/honeysql#updates

seancorfield 2020-12-30T03:23:09.272300Z

It talks about exactly this type of update.

benny 2020-12-30T04:02:24.272700Z

well shoot, thanks @seancorfield!

seancorfield 2020-12-30T04:04:13.273500Z

(a lot of honeysql isn't currently documented at all or, at best, poorly so I wasn't sure whether it was possible until I just read over the readme!)

seancorfield 2020-12-30T04:04:23.273800Z

HoneySQL v2 will be much better documented 🙂

benny 2020-12-30T04:12:42.274200Z

most of what i need is there, i just needed to look better 😉