Skip to content

Commit

Permalink
fix: add location info to sqlite ast (#2298)
Browse files Browse the repository at this point in the history
  • Loading branch information
orisano committed Jun 7, 2023
1 parent a022593 commit 9c64cfa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
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

0 comments on commit 9c64cfa

Please sign in to comment.