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
2 changes: 1 addition & 1 deletion crates/squawk_parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4211,7 +4211,7 @@ fn opt_as_col_label(p: &mut Parser<'_>) -> bool {
}

fn opt_target_list(p: &mut Parser) -> Option<CompletedMarker> {
if !p.at_ts(TARGET_LIST_START) {
if !p.at_ts(TARGET_LIST_START) || p.at(SELECT_KW) {
return None;
}
let m = p.start();
Expand Down
4 changes: 4 additions & 0 deletions crates/squawk_parser/tests/data/err/select.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ select 1 in c;
-- type cast must use a string literal
select numeric 1234;

-- regression test: this would cause the parser to get stuck & panic, now it
-- warns about a missing semicolon
select select;

-- trailing comma at EOF
select 1,
17 changes: 15 additions & 2 deletions crates/squawk_parser/tests/snapshots/tests__select_err.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
source: crates/squawk_parser/tests/tests.rs
input_file: crates/squawk_parser/tests/data/err/select.sql
snapshot_kind: text
---
SOURCE_FILE
COMMENT "--- via https://duckdb.org/docs/stable/sql/dialect/friendly_sql.html#trailing-commas"
Expand Down Expand Up @@ -209,6 +208,19 @@ SOURCE_FILE
INT_NUMBER "1234"
SEMICOLON ";"
WHITESPACE "\n\n"
COMMENT "-- regression test: this would cause the parser to get stuck & panic, now it"
WHITESPACE "\n"
COMMENT "-- warns about a missing semicolon"
WHITESPACE "\n"
SELECT
SELECT_CLAUSE
SELECT_KW "select"
WHITESPACE " "
SELECT
SELECT_CLAUSE
SELECT_KW "select"
SEMICOLON ";"
WHITESPACE "\n\n"
COMMENT "-- trailing comma at EOF"
WHITESPACE "\n"
SELECT
Expand All @@ -233,4 +245,5 @@ ERROR@395: expected expression
ERROR@396: expected expression
ERROR@397: expected expression
ERROR@520: missing comma
ERROR@561: unexpected trailing comma
ERROR@646: expected SEMICOLON
ERROR@689: unexpected trailing comma
Loading