honeysql

Toby Moore 2025-09-11T10:37:39.513069Z

I'm having trouble trying to do an array value update in Postgres, am I correct in understanding this isn't possible at the moment? This is valid in postgres, I can replace an item in an array:

UPDATE "tablename"
SET "some_bool_array_col"[2] = false
WHERE "id" = 'a-uuid'
It should also work with a subquery for the array index However I don't think there's a way with honeysql to get a complicated value like that in the column target of the SET?
> (honey.sql/format
    {:update :tablename
     :set {[:at :some_array_col 5] 6}})

Execution error (ExceptionInfo) at honey.sql/name (sql.cljc:257).
expected symbol, found: class clojure.lang.PersistentVector

emccue 2025-09-11T12:30:15.789249Z

all things are possible through :raw, worst case scenario

Toby Moore 2025-09-11T12:52:07.248899Z

Yeah, I figured. Unfortunately it would effectively be the whole query though, rather than just the field that's difficult.

seancorfield 2025-09-11T12:53:02.090259Z

Create a GitHub issue and I will think about a solution. There's probably no real reason the key in the SET map should be so restricted.

👍 1
seancorfield 2025-09-11T17:02:28.259579Z

I started looking into this and... it's unpleasantly harder than I expected... but I'll keep digging. Part of the problem is that databases don't allow qualified names in SET (except MySQL!) so there's some logic in there to drop the ns qualifier if present... which doesn't flow through the whole of the expression formatter and, in particular, doesn't flow through any special syntax. I may have to introduce a dynvar to fix this 😞

seancorfield 2025-09-11T17:15:59.751829Z

Okay, there will be a new snapshot soon that should address this (or you can use git deps).

seancorfield 2025-09-11T17:17:37.414179Z

Oh, darn... this breaks some examples in the docs 😞

seancorfield 2025-09-11T17:27:32.401569Z

Alright, properly fixed now! There's a new snapshot (or git deps) for testing.

1
2025-09-11T15:36:30.920359Z

2025-09-11T17:14:57.137919Z

2025-09-11T17:17:47.992279Z

2025-09-11T17:23:40.056849Z

🙌 2
1