SQLite: Require ROWID after WITHOUT in table options
diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 47d24ac..820803c 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs
@@ -8951,7 +8951,7 @@ /// See <https://www.sqlite.org/lang_createtable.html>. fn parse_sqlite_table_options(&mut self) -> Result<SqliteTableOptions, ParserError> { let leading_comma = self.consume_token(&Token::Comma); - let Some(first) = self.maybe_parse_sqlite_table_option() else { + let Some(first) = self.maybe_parse_sqlite_table_option()? else { if leading_comma { self.prev_token(); } @@ -8960,7 +8960,7 @@ let mut options = Vec::with_capacity(2); options.push(first); while self.consume_token(&Token::Comma) { - match self.maybe_parse_sqlite_table_option() { + match self.maybe_parse_sqlite_table_option()? { Some(option) => options.push(option), None => return self.expected_ref("WITHOUT ROWID or STRICT", self.peek_token_ref()), } @@ -8971,13 +8971,16 @@ }) } - fn maybe_parse_sqlite_table_option(&mut self) -> Option<SqliteTableOption> { - if self.parse_keywords(&[Keyword::WITHOUT, Keyword::ROWID]) { - Some(SqliteTableOption::WithoutRowid) + fn maybe_parse_sqlite_table_option( + &mut self, + ) -> Result<Option<SqliteTableOption>, ParserError> { + if self.parse_keyword(Keyword::WITHOUT) { + self.expect_keyword_is(Keyword::ROWID)?; + Ok(Some(SqliteTableOption::WithoutRowid)) } else if self.parse_keyword(Keyword::STRICT) { - Some(SqliteTableOption::Strict) + Ok(Some(SqliteTableOption::Strict)) } else { - None + Ok(None) } }
diff --git a/tests/sqlparser_sqlite.rs b/tests/sqlparser_sqlite.rs index a5e18e6..653f337 100644 --- a/tests/sqlparser_sqlite.rs +++ b/tests/sqlparser_sqlite.rs
@@ -1022,10 +1022,7 @@ "Expected: end of statement, found: WITHOUT", ), (" STRICT,", "Expected: WITHOUT ROWID or STRICT, found: EOF"), - ( - " STRICT, WITHOUT", - "Expected: WITHOUT ROWID or STRICT, found: WITHOUT", - ), + (" STRICT, WITHOUT", "Expected: ROWID, found: EOF"), (",", "Expected: end of statement, found: ,"), (", , STRICT", "Expected: end of statement, found: ,"), ] {