-
Notifications
You must be signed in to change notification settings - Fork 867
Array indexes not correctly handled on update set #1532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was going to suggest using a type cast, but that also doesn't work https://play.sqlc.dev/p/31c401f520c8cc7166e02d8b8a3cb71a78a6dc89902877a5de45f83aca7ddc72 |
This works correctly. |
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 |
* fix(compiler): Pull in array information from analyzer Fixes #1532 * test(analyzer): Add testcase for #1574 * test: Added test for #1634 * test: Add test case for #1646 * test: Add test for #1714 * Fixes #1912 * test: Add case for #1916 * test: Add two test cases #1917 #1545 * test: Add case for #1979 * test: Add case for #1990
Fixed in v1.23.0. You can see an example here: https://play.sqlc.dev/p/3807c7209ed1e1c09fd5520223590e0ade7d7dfdfc49996ad57dbd818eb9f27a |
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.
Playground
https://play.sqlc.dev/p/a7c1a274a647d8c2452f4bc9cd93f8a76bf09c43745ea428859433edec18aaa1
The text was updated successfully, but these errors were encountered: