Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: parse unions
  • Loading branch information
juleswritescode committed Apr 12, 2025
commit c3df43a7ec2bb8038e8a14c1466c4fa1cd74528b
2 changes: 2 additions & 0 deletions crates/pgt_statement_splitter/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ impl Parser {
}

/// Look ahead to the next relevant token
/// Returns `None` if we are already at the last relevant token
fn look_ahead(&self) -> Option<&Token> {
// we need to look ahead to the next relevant token
let mut look_ahead_pos = self.next_pos + 1;
Expand All @@ -161,6 +162,7 @@ impl Parser {
}
}

/// Returns `None` if there are no previous relevant tokens
fn look_back(&self) -> Option<&Token> {
// we need to look back to the last relevant token
let mut look_back_pos = self.next_pos - 1;
Expand Down
6 changes: 6 additions & 0 deletions crates/pgt_statement_splitter/src/parser/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ pub(crate) fn unknown(p: &mut Parser, exclude: &[SyntaxKind]) {
SyntaxKind::Also,
// for create rule
SyntaxKind::Instead,
// for UNION
SyntaxKind::Union,
// for UNION ALL
SyntaxKind::All,
// for UNION ... EXCEPT
SyntaxKind::Except,
]
.iter()
.all(|x| Some(x) != prev.as_ref())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select 1 union all select 2;