Fork me on GitHub
#sql
<
2022-01-08
>
seancorfield00:01:50

That inspired another Friday afternoon horror 🙂

dev=> (let [id 123] (sql/format (assoc-in '{update table set {foo (coalesce submitted_at (now))} where [= id 0]} '[where 2] id)))
["UPDATE table SET foo = COALESCE(submitted_at, NOW()) WHERE id = ?" 123]

Cora (she/her)00:01:04

not brittle at all

Cora (she/her)00:01:50

it feels like honey.sql itself, not honey.sql.helpers, but I don't see anything special like this in there

Cora (she/her)00:01:31

or at least nothing seems similar enough to my eyes that I have an example of how you'd like it set up

Cora (she/her)00:01:47

oh wow, it's late

Cora (she/her)00:01:52

I'm gonna bounce then

seancorfield00:01:22

Yeah, I think honey.sql is the right place. I'll have to give the name some thought (naming is hard). next.jdbc.sql.builder has a similar construct called by-keys but that's a generic constructor for several map-to-SQL-params clauses.

seancorfield00:01:01

Since it'll be mostly used via honey.sql :as sql I suspect, maybe sql/condition? Maybe sql/map->= or sql/map= or similar?

Cora (she/her)00:01:03

sql/map->condition

1
👍 1