UPDATE operations don't allow updating subscripted array values
bug
The `:at` operator lets us index into arrays in SQL:
```clojure
(honey.sql/format {:select [[[:at :my-array 14]]]})
=> ["SELECT my_array[14]"]
(honey.sql/format {:select [[[:at :my-array {:select :value :from :some-cte}]]]})
=> ["SELECT my_array[(SELECT value FROM some_cte)]"]
```
It should be possible to use the same syntax in UPDATE statements. [From the postgres docs](https://www.postgresql.org/docs/current/arrays.html#ARRAYS-MODIFYING):
```sql
UPDATE sal_emp SET pay_by_quarter[4] = 15000
WHERE name = 'Bill';
-- or updated in a slice:
UPDATE sal_emp SET pay_by_quarter[1:2] = '{27000,27000}'
WHERE name = 'Carol';
```
However this can't be formatted in honeysql:
```clojure
(honey.sql/format {:update :tbl
:set {[:at :my-array 14] 99}})
Execution error (ExceptionInfo) at honey.sql/name (sql.cljc:257).
expected symbol, found: class clojure.lang.PersistentVector
```
关闭于 2025-09-11 0 条评论