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
6 changes: 5 additions & 1 deletion crates/squawk_parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2511,7 +2511,11 @@ fn with_query_clause(p: &mut Parser<'_>) -> Option<CompletedMarker> {
break;
}
if !p.eat(COMMA) {
break;
if p.at(IDENT) {
p.error("missing comma");
} else {
break;
}
}
}
Some(m.complete(p, WITH_CLAUSE))
Expand Down
9 changes: 9 additions & 0 deletions crates/squawk_parser/tests/data/err/select_cte.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ select * from t order by ordercol;
with t as (select 1)
search depth first by a, b c set ordercol
select * from t order by ordercol;

with
a as (
select 1
) -- <-- missing a comma
b as (
select 3
)
select 2;
54 changes: 54 additions & 0 deletions crates/squawk_parser/tests/snapshots/tests__select_cte_err.snap
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,62 @@ SOURCE_FILE
NAME_REF
IDENT "ordercol"
SEMICOLON ";"
WHITESPACE "\n\n"
SELECT
WITH_CLAUSE
WITH_KW "with"
WHITESPACE " \n "
WITH_TABLE
NAME
IDENT "a"
WHITESPACE " "
AS_KW "as"
WHITESPACE " "
L_PAREN "("
WHITESPACE "\n "
SELECT
SELECT_CLAUSE
SELECT_KW "select"
WHITESPACE " "
TARGET_LIST
TARGET
LITERAL
INT_NUMBER "1"
WHITESPACE "\n "
R_PAREN ")"
WHITESPACE " "
COMMENT "-- <-- missing a comma"
WHITESPACE "\n "
WITH_TABLE
NAME
IDENT "b"
WHITESPACE " "
AS_KW "as"
WHITESPACE " "
L_PAREN "("
WHITESPACE "\n "
SELECT
SELECT_CLAUSE
SELECT_KW "select"
WHITESPACE " "
TARGET_LIST
TARGET
LITERAL
INT_NUMBER "3"
WHITESPACE "\n "
R_PAREN ")"
WHITESPACE "\n"
SELECT_CLAUSE
SELECT_KW "select"
WHITESPACE " "
TARGET_LIST
TARGET
LITERAL
INT_NUMBER "2"
SEMICOLON ";"
WHITESPACE "\n"
---
ERROR@24: unexpected comma
ERROR@140: unexpected comma, expected a column name
ERROR@270: expected COMMA
ERROR@357: missing comma
Loading