Skip to content

Commit d2eae55

Browse files
committed
Fix MATCH_RECOGNIZE exclusion after symbol
1 parent 4912f72 commit d2eae55

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎src/parser/mod.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16854,6 +16854,10 @@ impl<'a> Parser<'a> {
1685416854
Token::Mul => RepetitionQuantifier::ZeroOrMore,
1685516855
Token::Plus => RepetitionQuantifier::OneOrMore,
1685616856
Token::Placeholder(s) if s == "?" => RepetitionQuantifier::AtMostOne,
16857+
Token::LBrace if matches!(self.peek_token_ref().token, Token::Minus) => {
16858+
self.prev_token();
16859+
return Ok(pattern);
16860+
}
1685716861
Token::LBrace => {
1685816862
// quantifier is a range like {n} or {n,} or {,m} or {n,m}
1685916863
let token = self.next_token();

‎tests/sqlparser_common.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13408,6 +13408,15 @@ fn test_match_recognize_patterns() {
1340813408
// exclusion
1340913409
check("{- FOO -}", Exclude(Named(Ident::new("FOO"))));
1341013410

13411+
// exclusion immediately after a symbol is concatenation, not a range quantifier
13412+
check(
13413+
"S1 {- S2 -}",
13414+
Concat(vec![
13415+
Symbol(Named(Ident::new("S1"))),
13416+
Exclude(Named(Ident::new("S2"))),
13417+
]),
13418+
);
13419+
1341113420
check(
1341213421
"PERMUTE(A, B, C)",
1341313422
Permute(vec![

0 commit comments

Comments
 (0)