Skip to content

Commit f7e1f4e

Browse files
committed
Remove PostgreSQL dialect check for PARTITION OF.
1 parent 997fae3 commit f7e1f4e

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

src/parser/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7888,9 +7888,7 @@ impl<'a> Parser<'a> {
78887888
let table_name = self.parse_object_name(allow_unquoted_hyphen)?;
78897889

78907890
// PostgreSQL PARTITION OF for child partition tables
7891-
let partition_of = if dialect_of!(self is PostgreSqlDialect | GenericDialect)
7892-
&& self.parse_keywords(&[Keyword::PARTITION, Keyword::OF])
7893-
{
7891+
let partition_of = if self.parse_keywords(&[Keyword::PARTITION, Keyword::OF]) {
78947892
Some(self.parse_object_name(allow_unquoted_hyphen)?)
78957893
} else {
78967894
None

tests/sqlparser_postgres.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8104,3 +8104,34 @@ CONSTRAINT check_date CHECK (order_date >= '2023-01-01')\
81048104
_ => panic!("Expected CreateTable"),
81058105
}
81068106
}
8107+
8108+
#[test]
8109+
fn parse_create_table_partition_of_works_without_dialect_check() {
8110+
use sqlparser::dialect::{GenericDialect, MySqlDialect, SQLiteDialect};
8111+
use sqlparser::test_utils::TestedDialects;
8112+
8113+
let sql = "CREATE TABLE measurement_y2006m02 PARTITION OF measurement FOR VALUES FROM ('2006-02-01') TO ('2006-03-01')";
8114+
let dialects = TestedDialects::new(vec![
8115+
Box::new(GenericDialect {}),
8116+
Box::new(PostgreSqlDialect {}),
8117+
Box::new(MySqlDialect {}),
8118+
Box::new(SQLiteDialect {}),
8119+
]);
8120+
match dialects.verified_stmt(sql) {
8121+
Statement::CreateTable(create_table) => {
8122+
assert_eq!("measurement_y2006m02", create_table.name.to_string());
8123+
assert_eq!(
8124+
Some(ObjectName::from(vec![Ident::new("measurement")])),
8125+
create_table.partition_of
8126+
);
8127+
match create_table.for_values {
8128+
Some(ForValues::From { from, to }) => {
8129+
assert_eq!(1, from.len());
8130+
assert_eq!(1, to.len());
8131+
}
8132+
_ => panic!("Expected ForValues::From"),
8133+
}
8134+
}
8135+
_ => panic!("Expected CreateTable"),
8136+
}
8137+
}

0 commit comments

Comments
 (0)