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
14 changes: 14 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"recommendations": [
"ckolkman.vscode-postgres",
"rust-lang.rust-analyzer",
"usernamehw.errorlens",
"dbaeumer.vscode-eslint",
"mitsuhiko.insta",
"esbenp.prettier-vscode",
"vitest.explorer",
"binhtran432k.ungrammar-language-features",
"sleistner.vscode-fileutils",
"tamasfe.even-better-toml"
]
}
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"[sql]": {
"files.associations": {
"*.sql": "postgres"
},
"[postgres]": {
"editor.tabSize": 2
},
"[ungrammar]": {
Expand Down
36 changes: 18 additions & 18 deletions crates/squawk_parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,26 +286,26 @@ fn position_fn(p: &mut Parser<'_>) -> CompletedMarker {
fn trim_fn(p: &mut Parser<'_>) -> CompletedMarker {
assert!(p.at(TRIM_KW));
custom_fn(p, TRIM_KW, |p| {
if p.eat(BOTH_KW) {
let _ = p.eat(BOTH_KW) || p.eat(LEADING_KW) || p.eat(TRAILING_KW);
// | FROM expr_list
// | a_expr FROM expr_list
// | expr_list
if p.eat(FROM_KW) {
if !expr_list(p) {
p.error("expected expression")
}
} else {
if expr(p).is_none() {
p.error("expected expression");
}
if p.eat(FROM_KW) {
if expr(p).is_none() {
p.error("expected an expression");
}
expr_list(p);
} else {
if expr(p).is_none() {
p.error("expected an expression");
}
if p.eat(FROM_KW) && expr(p).is_none() {
p.error("expected an expression");
if p.eat(COMMA) {
expr_list(p);
}
}
} else if p.eat(LEADING_KW) || p.eat(TRAILING_KW) {
if expr(p).is_none() {
p.error("expected an expression");
}
} else if expr(p).is_none() {
p.error("expected an expression");
}
};
})
}

Expand Down Expand Up @@ -11970,14 +11970,14 @@ fn with(p: &mut Parser<'_>, m: Option<Marker>) -> Option<CompletedMarker> {
with_query_clause(p);
match p.current() {
DELETE_KW => Some(delete(p, Some(m))),
SELECT_KW | TABLE_KW => select(p, Some(m)),
SELECT_KW | TABLE_KW | VALUES_KW => select(p, Some(m)),
INSERT_KW => Some(insert(p, Some(m))),
UPDATE_KW => Some(update(p, Some(m))),
MERGE_KW => Some(merge(p, Some(m))),
_ => {
m.abandon(p);
p.error(format!(
"expected DELETE, SELECT, TABLE, UPDATE, or MERGE, got: {:?}",
"expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: {:?}",
p.current()
));
None
Expand Down
4 changes: 2 additions & 2 deletions crates/squawk_parser/tests/data/regression_suite/vacuum.sql
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ DROP TABLE only_inh_parent CASCADE;

-- parenthesized syntax for ANALYZE
ANALYZE (VERBOSE) does_not_exist;
ANALYZE (nonexistent-arg) does_not_exist;
ANALYZE (nonexistentarg) does_not_exit;
-- ANALYZE (nonexistent-arg) does_not_exist;
-- ANALYZE (nonexistentarg) does_not_exit;

-- ensure argument order independence, and that SKIP_LOCKED on non-existing
-- relation still errors out. Suppress WARNING messages caused by concurrent
Expand Down
4 changes: 2 additions & 2 deletions crates/squawk_parser/tests/data/regression_suite/with.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1703,8 +1703,8 @@ VALUES(FALSE);
DROP RULE y_rule ON y;

-- check that parser lookahead for WITH doesn't cause any odd behavior
create table foo (with baz); -- fail, WITH is a reserved word
create table foo (with ordinality); -- fail, WITH is a reserved word
-- create table foo (with baz); -- fail, WITH is a reserved word
-- create table foo (with ordinality); -- fail, WITH is a reserved word
with ordinality as (select 1 as x) select * from ordinality;

-- check sane response to attempt to modify CTE relation
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ ERROR@62378: expected MATCHED, or NOT MATCHED
ERROR@62378: expected THEN_KW
ERROR@62378: expected INSERT, UPDATE, DELETE, or DO NOTHING
ERROR@62378: expected R_PAREN
ERROR@62378: expected DELETE, SELECT, TABLE, UPDATE, or MERGE, got: IDENT
ERROR@62378: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: IDENT
ERROR@62378: expected SELECT, INSERT, UPDATE, DELETE, MERGE, VALUES, EXECUTE, DECLARE, CREATE TABLE AS, or CREATE MATERIALIZED VIEW AS
ERROR@62378: expected SEMICOLON
ERROR@62379: expected command, found IDENT
Expand Down Expand Up @@ -283,7 +283,7 @@ ERROR@62673: expected MATCHED, or NOT MATCHED
ERROR@62673: expected THEN_KW
ERROR@62673: expected INSERT, UPDATE, DELETE, or DO NOTHING
ERROR@62673: expected R_PAREN
ERROR@62673: expected DELETE, SELECT, TABLE, UPDATE, or MERGE, got: IDENT
ERROR@62673: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: IDENT
ERROR@62674: expected command, found IDENT
ERROR@62685: expected command, found IDENT
ERROR@62689: expected command, found ON_KW
Expand Down
Loading
Loading