Skip to content

fix(sqlite): honor aliases in RETURNING when naming result columns - #4681

Open
kevin9327 wants to merge 1 commit into
sqlc-dev:mainfrom
kevin9327:fix/sqlite-returning-aliases
Open

kevin9327 wants to merge 1 commit into
sqlc-dev:mainfrom
kevin9327:fix/sqlite-returning-aliases

Conversation

@kevin9327

Copy link
Copy Markdown

Summary

SQLite RETURNING aliases were ignored when naming generated result columns. convertReturning built each ResTarget from the expression but never set Name, unlike convertResultColumns for SELECT.

Aliases (with or without AS, including quoted identifiers) are now copied onto the target, so names match what SQLite itself reports. This covers INSERT, INSERT … ON CONFLICT DO UPDATE, UPDATE and DELETE.

Fixes #4680

Test plan

Added internal/endtoend/testdata/returning_aliases/sqlite covering the cases from the issue. Goldens generated with the fix show NewID/Doubled (and the other expected names) instead of ID/Column2.

go test -count=1 -timeout 180s -run 'TestReplay/.*/returning' ./internal/endtoend

AI assistance

This change was prepared with assistance from Grok Bot. I reviewed the SQLite converter against the SELECT path, generated the goldens before and after the fix, and ran the returning end-to-end tests locally.

convertReturning copied each RETURNING expression into a ResTarget but
never set ResTarget.Name from the column alias, so field names came from
the underlying column or ColumnN. SELECT already passed the alias
through convertResultColumns.

Fixes sqlc-dev#4680

Signed-off-by: kevin9327 <5299031+kevin9327@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlite: aliases in RETURNING are ignored when naming result columns

1 participant