Skip to content

Commit 952c236

Browse files
committed
Remove PostgreSQL dialect check for PARTITION OF.
1 parent fae2648 commit 952c236

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
@@ -8112,3 +8112,34 @@ CONSTRAINT check_date CHECK (order_date >= '2023-01-01')\
81128112
_ => panic!("Expected CreateTable"),
81138113
}
81148114
}
8115+
8116+
#[test]
8117+
fn parse_create_table_partition_of_works_without_dialect_check() {
8118+
use sqlparser::dialect::{GenericDialect, MySqlDialect, SQLiteDialect};
8119+
use sqlparser::test_utils::TestedDialects;
8120+
8121+
let sql = "CREATE TABLE measurement_y2006m02 PARTITION OF measurement FOR VALUES FROM ('2006-02-01') TO ('2006-03-01')";
8122+
let dialects = TestedDialects::new(vec![
8123+
Box::new(GenericDialect {}),
8124+
Box::new(PostgreSqlDialect {}),
8125+
Box::new(MySqlDialect {}),
8126+
Box::new(SQLiteDialect {}),
8127+
]);
8128+
match dialects.verified_stmt(sql) {
8129+
Statement::CreateTable(create_table) => {
8130+
assert_eq!("measurement_y2006m02", create_table.name.to_string());
8131+
assert_eq!(
8132+
Some(ObjectName::from(vec![Ident::new("measurement")])),
8133+
create_table.partition_of
8134+
);
8135+
match create_table.for_values {
8136+
Some(ForValues::From { from, to }) => {
8137+
assert_eq!(1, from.len());
8138+
assert_eq!(1, to.len());
8139+
}
8140+
_ => panic!("Expected ForValues::From"),
8141+
}
8142+
}
8143+
_ => panic!("Expected CreateTable"),
8144+
}
8145+
}

0 commit comments

Comments
 (0)