Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ast/boolean_like_expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type BooleanLikeExpression struct {
SecondExpression ScalarExpression
EscapeExpression ScalarExpression
NotDefined bool
OdbcEscape bool
}

func (b *BooleanLikeExpression) node() {}
Expand Down
4 changes: 2 additions & 2 deletions ast/set_variable_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func (s *SetVariableStatement) statement() {}

// CursorDefinition represents a cursor definition.
type CursorDefinition struct {
Options []*CursorOption `json:"Options,omitempty"`
Select QueryExpression `json:"Select,omitempty"`
Options []*CursorOption `json:"Options,omitempty"`
Select *SelectStatement `json:"Select,omitempty"`
}

// CursorOption represents a cursor option like SCROLL or DYNAMIC.
Expand Down
12 changes: 4 additions & 8 deletions parser/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ func booleanExpressionToJSON(expr ast.BooleanExpression) jsonNode {
return node
case *ast.BooleanLikeExpression:
node := jsonNode{
"$type": "BooleanLikeExpression",
"$type": "LikePredicate",
}
if e.FirstExpression != nil {
node["FirstExpression"] = scalarExpressionToJSON(e.FirstExpression)
Expand All @@ -1675,6 +1675,7 @@ func booleanExpressionToJSON(expr ast.BooleanExpression) jsonNode {
node["EscapeExpression"] = scalarExpressionToJSON(e.EscapeExpression)
}
node["NotDefined"] = e.NotDefined
node["OdbcEscape"] = e.OdbcEscape
return node
case *ast.BooleanTernaryExpression:
node := jsonNode{
Expand Down Expand Up @@ -2216,7 +2217,7 @@ func cursorDefinitionToJSON(cd *ast.CursorDefinition) jsonNode {
node["Options"] = opts
}
if cd.Select != nil {
node["Select"] = queryExpressionToJSON(cd.Select)
node["Select"] = selectStatementToJSON(cd.Select)
}
return node
}
Expand Down Expand Up @@ -7552,12 +7553,7 @@ func declareCursorDefinitionToJSON(d *ast.CursorDefinition) jsonNode {
node["Options"] = opts
}
if d.Select != nil {
// For DeclareCursorStatement, we need to wrap the QueryExpression in a SelectStatement format
selectNode := jsonNode{
"$type": "SelectStatement",
"QueryExpression": queryExpressionToJSON(d.Select),
}
node["Select"] = selectNode
node["Select"] = selectStatementToJSON(d.Select)
}
return node
}
7 changes: 3 additions & 4 deletions parser/parse_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ func (p *Parser) parseSetVariableStatement() (ast.Statement, error) {
if err != nil {
return nil, err
}
cursorDef.Select = qe
cursorDef.Select = &ast.SelectStatement{QueryExpression: qe}
}
stmt.CursorDefinition = cursorDef
} else {
Expand Down Expand Up @@ -5838,13 +5838,12 @@ func (p *Parser) parseDeclareCursorStatementContinued(cursorName *ast.Identifier
p.nextToken()
}

// Parse SELECT statement and extract its QueryExpression
// Parse SELECT statement
selectStmt, err := p.parseSelectStatement()
if err != nil {
return nil, err
}
// CursorDefinition.Select is a QueryExpression, so we extract it from the SelectStatement
stmt.CursorDefinition.Select = selectStmt.QueryExpression
stmt.CursorDefinition.Select = selectStmt

// Skip optional semicolon
if p.curTok.Type == TokenSemicolon {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"todo": true}
{}
2 changes: 1 addition & 1 deletion parser/testdata/SetVariableStatementTests/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"todo": true}
{}
Loading