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.PersistentVectorall things are possible through :raw, worst case scenario
Yeah, I figured. Unfortunately it would effectively be the whole query though, rather than just the field that's difficult.
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.
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 😞
Okay, there will be a new snapshot soon that should address this (or you can use git deps).
Oh, darn... this breaks some examples in the docs 😞
Alright, properly fixed now! There's a new snapshot (or git deps) for testing.