Skip to content

Commit 380b24e

Browse files
kyleconroyclaude
andcommitted
Add INDEX = value syntax support for table hints
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 744ea52 commit 380b24e

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

parser/parse_select.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,6 +3126,34 @@ func (p *Parser) parseTableHint() (ast.TableHintType, error) {
31263126
hint := &ast.IndexTableHint{
31273127
HintKind: "Index",
31283128
}
3129+
// Handle INDEX = value syntax (alternative to INDEX(value))
3130+
if p.curTok.Type == TokenEquals {
3131+
p.nextToken() // consume =
3132+
var iov *ast.IdentifierOrValueExpression
3133+
if p.curTok.Type == TokenNumber {
3134+
iov = &ast.IdentifierOrValueExpression{
3135+
Value: p.curTok.Literal,
3136+
ValueExpression: &ast.IntegerLiteral{
3137+
LiteralType: "Integer",
3138+
Value: p.curTok.Literal,
3139+
},
3140+
}
3141+
p.nextToken()
3142+
} else if p.curTok.Type == TokenIdent {
3143+
iov = &ast.IdentifierOrValueExpression{
3144+
Value: p.curTok.Literal,
3145+
Identifier: &ast.Identifier{
3146+
Value: p.curTok.Literal,
3147+
QuoteType: "NotQuoted",
3148+
},
3149+
}
3150+
p.nextToken()
3151+
}
3152+
if iov != nil {
3153+
hint.IndexValues = append(hint.IndexValues, iov)
3154+
}
3155+
return hint, nil
3156+
}
31293157
if p.curTok.Type == TokenLParen {
31303158
p.nextToken() // consume (
31313159
for p.curTok.Type != TokenRParen && p.curTok.Type != TokenEOF {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}

0 commit comments

Comments
 (0)