Skip to content

Commit c476b26

Browse files
kyleconroyclaude
andcommitted
Handle identifier literals in OPENROWSET BULK options
- Parse TRUE, FALSE, RAW, ACP, WIDECHAR, CHAR as IdentifierLiteral instead of ColumnReferenceExpression for OPENROWSET BULK options - Fixes HEADER_ROW = TRUE and similar option values Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1ddac5f commit c476b26

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

parser/parse_dml.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,36 @@ func (p *Parser) parseOpenRowsetBulkOption() (ast.BulkInsertOption, error) {
924924

925925
if p.curTok.Type == TokenEquals {
926926
p.nextToken()
927-
value, err := p.parseScalarExpression()
928-
if err != nil {
929-
return nil, err
927+
var value ast.ScalarExpression
928+
929+
// Check if value is a bare identifier (e.g., TRUE, FALSE, RAW, ACP, widechar)
930+
// that should be treated as IdentifierLiteral, not a column reference
931+
if p.curTok.Type == TokenIdent && !strings.HasPrefix(p.curTok.Literal, "@") &&
932+
p.peekTok.Type != TokenDot && p.peekTok.Type != TokenLParen {
933+
// For options like HEADER_ROW = TRUE, CODEPAGE = 'RAW' or 'ACP', DATAFILETYPE = 'widechar'
934+
// These are identifier literals, not column references
935+
upperVal := strings.ToUpper(p.curTok.Literal)
936+
if upperVal == "TRUE" || upperVal == "FALSE" || upperVal == "RAW" ||
937+
upperVal == "ACP" || upperVal == "WIDECHAR" || upperVal == "CHAR" {
938+
value = &ast.IdentifierLiteral{
939+
LiteralType: "Identifier",
940+
QuoteType: "NotQuoted",
941+
Value: p.curTok.Literal,
942+
}
943+
p.nextToken()
944+
} else {
945+
var err error
946+
value, err = p.parseScalarExpression()
947+
if err != nil {
948+
return nil, err
949+
}
950+
}
951+
} else {
952+
var err error
953+
value, err = p.parseScalarExpression()
954+
if err != nil {
955+
return nil, err
956+
}
930957
}
931958
return &ast.LiteralBulkInsertOption{
932959
OptionKind: optionKind,
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)