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
8 changes: 7 additions & 1 deletion parser/ast_expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ func (f *FunctionExpr) Pos() Pos {
}

func (f *FunctionExpr) End() Pos {
return f.Params.RightParenPos + 1
params := f.Params
// Bare EXCEPT col uses the column's bounds as its synthetic paren
// positions, so the right position is already exclusive.
if items := params.Items; items != nil && params.LeftParenPos == items.Pos() && params.RightParenPos == items.End() {
return params.RightParenPos
}
return params.RightParenPos + 1
}

func (f *FunctionExpr) Accept(visitor ASTVisitor) error {
Expand Down
2 changes: 2 additions & 0 deletions parser/position_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func TestSourceSpansCoverReportedNodes(t *testing.T) {
{"SELECT ?", "?", func(e Expr) Expr { return e.(*SelectQuery).SelectItems[0].Expr }},
{"SELECT 'abc'", "'abc'", func(e Expr) Expr { return e.(*SelectQuery).SelectItems[0].Expr }},
{"SELECT f(1)", "f(1)", func(e Expr) Expr { return e.(*SelectQuery).SelectItems[0].Expr }},
{"SELECT t.* EXCEPT b, c FROM t", "EXCEPT b", func(e Expr) Expr { return e.(*SelectQuery).SelectItems[0].Modifiers[0] }},
{"SELECT t.* EXCEPT (b), c FROM t", "EXCEPT (b)", func(e Expr) Expr { return e.(*SelectQuery).SelectItems[0].Modifiers[0] }},
} {
t.Run(tc.sql, func(t *testing.T) {
stmt := parseOneStmt(t, tc.sql)
Expand Down
Loading