Skip to content

Commit 9c64cfa

Browse files
authored
fix: add location info to sqlite ast (#2298)
1 parent a022593 commit 9c64cfa

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# package querytest
2-
query.sql:9:1: column reference "invalid_reference" not found
2+
query.sql:11:10: column reference "invalid_reference" not found
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# package querytest
2-
query.sql:9:1: table alias "p" does not exist
2+
query.sql:11:9: table alias "p" does not exist

Diff for: internal/engine/sqlite/convert.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ func (c *cc) convertColumnNameExpr(n *parser.Expr_qualified_column_nameContext)
265265
Fields: &ast.List{
266266
Items: items,
267267
},
268+
Location: n.GetStart().GetStart(),
268269
}
269270
}
270271

@@ -545,15 +546,17 @@ func (c *cc) convertLiteral(n *parser.Expr_literalContext) ast.Node {
545546
if literal.NUMERIC_LITERAL() != nil {
546547
i, _ := strconv.ParseInt(literal.GetText(), 10, 64)
547548
return &ast.A_Const{
548-
Val: &ast.Integer{Ival: i},
549+
Val: &ast.Integer{Ival: i},
550+
Location: n.GetStart().GetStart(),
549551
}
550552
}
551553

552554
if literal.STRING_LITERAL() != nil {
553555
// remove surrounding single quote
554556
text := literal.GetText()
555557
return &ast.A_Const{
556-
Val: &ast.String{Str: text[1 : len(text)-1]},
558+
Val: &ast.String{Str: text[1 : len(text)-1]},
559+
Location: n.GetStart().GetStart(),
557560
}
558561
}
559562

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

566569
return &ast.A_Const{
567-
Val: &ast.Integer{Ival: i},
570+
Val: &ast.Integer{Ival: i},
571+
Location: n.GetStart().GetStart(),
568572
}
569573
}
570574
}

0 commit comments

Comments
 (0)