Skip to content

Commit 67c0a50

Browse files
authored
fix: cte (#263)
1 parent f2570b5 commit 67c0a50

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Diff for: crates/pgt_statement_splitter/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ mod tests {
142142
.expect_statements(vec!["insert into tbl (id) select 1", "select 3"]);
143143
}
144144

145+
#[test]
146+
fn with_cte() {
147+
Tester::from("with test as (select 1 as id) select * from test;")
148+
.expect_statements(vec!["with test as (select 1 as id) select * from test;"]);
149+
}
150+
145151
#[test]
146152
fn case() {
147153
Tester::from("select case when select 2 then 1 else 0 end")

Diff for: crates/pgt_statement_splitter/src/parser/dml.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use pgt_lexer::SyntaxKind;
22

33
use super::{
44
Parser,
5-
common::{parenthesis, statement, unknown},
5+
common::{parenthesis, unknown},
66
};
77

88
pub(crate) fn cte(p: &mut Parser) {
@@ -18,7 +18,16 @@ pub(crate) fn cte(p: &mut Parser) {
1818
}
1919
}
2020

21-
statement(p);
21+
unknown(
22+
p,
23+
&[
24+
SyntaxKind::Select,
25+
SyntaxKind::Insert,
26+
SyntaxKind::Update,
27+
SyntaxKind::DeleteP,
28+
SyntaxKind::Merge,
29+
],
30+
);
2231
}
2332

2433
pub(crate) fn select(p: &mut Parser) {

0 commit comments

Comments
 (0)