Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(engine/sqlite): add location info to sqlite ast #2298

Merged
merged 1 commit into from
Jun 7, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# package querytest
query.sql:9:1: column reference "invalid_reference" not found
query.sql:11:10: column reference "invalid_reference" not found
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# package querytest
query.sql:9:1: table alias "p" does not exist
query.sql:11:9: table alias "p" does not exist
10 changes: 7 additions & 3 deletions internal/engine/sqlite/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func (c *cc) convertColumnNameExpr(n *parser.Expr_qualified_column_nameContext)
Fields: &ast.List{
Items: items,
},
Location: n.GetStart().GetStart(),
}
}

Expand Down Expand Up @@ -545,15 +546,17 @@ func (c *cc) convertLiteral(n *parser.Expr_literalContext) ast.Node {
if literal.NUMERIC_LITERAL() != nil {
i, _ := strconv.ParseInt(literal.GetText(), 10, 64)
return &ast.A_Const{
Val: &ast.Integer{Ival: i},
Val: &ast.Integer{Ival: i},
Location: n.GetStart().GetStart(),
}
}

if literal.STRING_LITERAL() != nil {
// remove surrounding single quote
text := literal.GetText()
return &ast.A_Const{
Val: &ast.String{Str: text[1 : len(text)-1]},
Val: &ast.String{Str: text[1 : len(text)-1]},
Location: n.GetStart().GetStart(),
}
}

Expand All @@ -564,7 +567,8 @@ func (c *cc) convertLiteral(n *parser.Expr_literalContext) ast.Node {
}

return &ast.A_Const{
Val: &ast.Integer{Ival: i},
Val: &ast.Integer{Ival: i},
Location: n.GetStart().GetStart(),
}
}
}
Expand Down