Skip to content

Commit e2dba40

Browse files
committed
fix: handle create rule with select
1 parent 1308770 commit e2dba40

File tree

1 file changed

+15
-2
lines changed
  • crates/pg_statement_splitter/src/parser

1 file changed

+15
-2
lines changed

crates/pg_statement_splitter/src/parser/common.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,23 @@ pub(crate) fn unknown(p: &mut Parser, exclude: &[SyntaxKind]) {
124124
}
125125
t => match at_statement_start(t.kind, exclude) {
126126
Some(SyntaxKind::Select) => {
127-
// we need to check for `as` here to not break on `select as`
128-
if p.look_back().map(|t| t.kind) != Some(SyntaxKind::As) {
127+
let prev = p.look_back().map(|t| t.kind);
128+
if [
129+
// for create view / table as
130+
SyntaxKind::As,
131+
// for create rule
132+
SyntaxKind::On,
133+
// for create rule
134+
SyntaxKind::Also,
135+
// for create rule
136+
SyntaxKind::Instead,
137+
]
138+
.iter()
139+
.all(|x| Some(x) != prev.as_ref())
140+
{
129141
break;
130142
}
143+
131144
p.advance();
132145
}
133146
Some(SyntaxKind::Insert) | Some(SyntaxKind::Update) | Some(SyntaxKind::DeleteP) => {

0 commit comments

Comments
 (0)