Skip to content

Commit 791dbd9

Browse files
committed
fix
1 parent a612d1b commit 791dbd9

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

crates/squawk_parser/src/grammar.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,13 @@ fn opt_paren_select(p: &mut Parser<'_>) -> Option<CompletedMarker> {
114114
}
115115
}
116116
p.expect(R_PAREN);
117-
let cm = m.complete(p, PAREN_SELECT);
118-
let cm = if p.at_ts(COMPOUND_SELECT_FIRST) {
119-
compound_select(p, cm)
117+
if p.at_ts(COMPOUND_SELECT_FIRST) {
118+
let cm = m.complete(p, PAREN_SELECT);
119+
Some(compound_select(p, cm))
120120
} else {
121-
cm
122-
};
123-
select_trailing_clauses(p);
124-
Some(cm)
121+
select_trailing_clauses(p);
122+
Some(m.complete(p, PAREN_SELECT))
123+
}
125124
}
126125

127126
const SELECT_FIRST: TokenSet = TokenSet::new(&[SELECT_KW, TABLE_KW, WITH_KW, VALUES_KW]);

crates/squawk_parser/tests/data/ok/precedence.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ SELECT (((SELECT 2)) + 3);
33
SELECT (((SELECT 2)) UNION SELECT 2);
44

55

6-
-- TODO!
76
SELECT foo UNION SELECT bar ORDER BY baz;
87
-- equal to:
98
(SELECT foo UNION SELECT bar) ORDER BY baz;

crates/squawk_parser/tests/snapshots/tests__precedence_ok.snap

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ SOURCE_FILE
7373
R_PAREN ")"
7474
SEMICOLON ";"
7575
WHITESPACE "\n\n\n"
76-
COMMENT "-- TODO!"
77-
WHITESPACE "\n"
7876
COMPOUND_SELECT
7977
SELECT
8078
SELECT_CLAUSE
@@ -130,13 +128,13 @@ SOURCE_FILE
130128
NAME_REF
131129
IDENT "bar"
132130
R_PAREN ")"
133-
WHITESPACE " "
134-
ORDER_BY_CLAUSE
135-
ORDER_KW "ORDER"
136-
WHITESPACE " "
137-
BY_KW "BY"
138131
WHITESPACE " "
139-
NAME_REF
140-
IDENT "baz"
132+
ORDER_BY_CLAUSE
133+
ORDER_KW "ORDER"
134+
WHITESPACE " "
135+
BY_KW "BY"
136+
WHITESPACE " "
137+
NAME_REF
138+
IDENT "baz"
141139
SEMICOLON ";"
142140
WHITESPACE "\n"

0 commit comments

Comments
 (0)