Repository navigation
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SQLite
RETURNINGaliases were ignored when naming generated result columns.convertReturningbuilt eachResTargetfrom the expression but never setName, unlikeconvertResultColumnsforSELECT.Aliases (with or without
AS, including quoted identifiers) are now copied onto the target, so names match what SQLite itself reports. This coversINSERT,INSERT … ON CONFLICT DO UPDATE,UPDATEandDELETE.Fixes #4680
Test plan
Added
internal/endtoend/testdata/returning_aliases/sqlitecovering the cases from the issue. Goldens generated with the fix showNewID/Doubled(and the other expected names) instead ofID/Column2.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.