You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Array indexes not correctly handled on update set #1532
I have a SQL query in my project that is attempting to update an array at a specific index but it is not being handled correctly. I was able to replicate this issue in a separate project and pasted the sample query below.
-- name: UpdateRow :one
update temp
set places[$1] = $2
where id=$3
RETURNING *;
The generated code treats places[$1] as an array input parameter instead of accepting $1 as the index of the places column.
I'm not sure that's correct though. The array index has the correct type but the assignment to the array element should be a string I think right? Not an array of strings?
Activity
kyleconroy commentedon Sep 22, 2023
I was going to suggest using a type cast, but that also doesn't work
https://play.sqlc.dev/p/31c401f520c8cc7166e02d8b8a3cb71a78a6dc89902877a5de45f83aca7ddc72
orisano commentedon Sep 23, 2023
This works correctly.
https://play.sqlc.dev/p/d472b30aa6c2fac886b797341eaa84343bd8676f825a5a597a64acbaa2dcd33d
andrewmbenton commentedon Oct 16, 2023
I'm not sure that's correct though. The array index has the correct type but the assignment to the array element should be a string I think right? Not an array of strings?
I think casting
@name::textwill work though: https://play.sqlc.dev/p/bad6f4c76953c419bcdb391b04498e81c3b39f69896ee28fd110d3803448ebf4fix(compiler): Pull in array information from analyzer
fix(compiler): Pull in array information from analyzer (#2864)
kyleconroy commentedon Oct 25, 2023
Fixed in v1.23.0. You can see an example here: https://play.sqlc.dev/p/3807c7209ed1e1c09fd5520223590e0ade7d7dfdfc49996ad57dbd818eb9f27a
fix(compiler): Pull in array information from analyzer (sqlc-dev#2864)