Skip to content

Commit 294c76b

Browse files
kyleconroyclaude
andcommitted
Fix REPLACE transformer consuming comma from SELECT clause
When parsing `SELECT * REPLACE expr AS name, other_col` without parentheses, the REPLACE parser was consuming the comma before breaking, preventing the caller from seeing there's another select item. Now the comma is only consumed when inside parentheses. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e99acd5 commit 294c76b

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

parser/expression.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3019,11 +3019,12 @@ func (p *Parser) parseAsteriskReplace(asterisk *ast.Asterisk) ast.Expression {
30193019
replaces = append(replaces, replace)
30203020

30213021
if p.currentIs(token.COMMA) {
3022-
p.nextToken()
3023-
// If no parens and we see comma, might be end of select column
3022+
// If no parens and we see comma, this is the end of the REPLACE clause
3023+
// Don't consume the comma - let the caller handle it for the next select item
30243024
if !hasParens {
30253025
break
30263026
}
3027+
p.nextToken() // Only consume comma if inside parentheses
30273028
} else if !hasParens {
30283029
break
30293030
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt67": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)