Skip to content

Commit

Permalink
Error on dangling NO in CREATE SEQUENCE options (#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-rph authored Jan 24, 2024
1 parent 3a6d3ec commit 498708c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8700,13 +8700,12 @@ impl<'a> Parser<'a> {
)));
}
// [ [ NO ] CYCLE ]
if self.parse_keywords(&[Keyword::NO]) {
if self.parse_keywords(&[Keyword::CYCLE]) {
sequence_options.push(SequenceOptions::Cycle(true));
}
if self.parse_keywords(&[Keyword::NO, Keyword::CYCLE]) {
sequence_options.push(SequenceOptions::Cycle(true));
} else if self.parse_keywords(&[Keyword::CYCLE]) {
sequence_options.push(SequenceOptions::Cycle(false));
}

Ok(sequence_options)
}

Expand Down
5 changes: 5 additions & 0 deletions tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ fn parse_create_sequence() {
sql6,
"CREATE TEMPORARY SEQUENCE IF NOT EXISTS name3 INCREMENT 1 NO MINVALUE MAXVALUE 20 OWNED BY NONE",
);

assert!(matches!(
pg().parse_sql_statements("CREATE SEQUENCE foo INCREMENT 1 NO MINVALUE NO"),
Err(ParserError::ParserError(_))
));
}

#[test]
Expand Down

0 comments on commit 498708c

Please sign in to comment.