diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 6ebf5c62..216f544e 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -7888,9 +7888,7 @@ impl<'a> Parser<'a> { let table_name = self.parse_object_name(allow_unquoted_hyphen)?; // PostgreSQL PARTITION OF for child partition tables - let partition_of = if dialect_of!(self is PostgreSqlDialect | GenericDialect) - && self.parse_keywords(&[Keyword::PARTITION, Keyword::OF]) - { + let partition_of = if self.parse_keywords(&[Keyword::PARTITION, Keyword::OF]) { Some(self.parse_object_name(allow_unquoted_hyphen)?) } else { None diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs index 717112d1..5fbd35b2 100644 --- a/tests/sqlparser_postgres.rs +++ b/tests/sqlparser_postgres.rs @@ -8104,3 +8104,34 @@ CONSTRAINT check_date CHECK (order_date >= '2023-01-01')\ _ => panic!("Expected CreateTable"), } } + +#[test] +fn parse_create_table_partition_of_works_without_dialect_check() { + use sqlparser::dialect::{GenericDialect, MySqlDialect, SQLiteDialect}; + use sqlparser::test_utils::TestedDialects; + + let sql = "CREATE TABLE measurement_y2006m02 PARTITION OF measurement FOR VALUES FROM ('2006-02-01') TO ('2006-03-01')"; + let dialects = TestedDialects::new(vec![ + Box::new(GenericDialect {}), + Box::new(PostgreSqlDialect {}), + Box::new(MySqlDialect {}), + Box::new(SQLiteDialect {}), + ]); + match dialects.verified_stmt(sql) { + Statement::CreateTable(create_table) => { + assert_eq!("measurement_y2006m02", create_table.name.to_string()); + assert_eq!( + Some(ObjectName::from(vec![Ident::new("measurement")])), + create_table.partition_of + ); + match create_table.for_values { + Some(ForValues::From { from, to }) => { + assert_eq!(1, from.len()); + assert_eq!(1, to.len()); + } + _ => panic!("Expected ForValues::From"), + } + } + _ => panic!("Expected CreateTable"), + } +}