Support parsing optional nulls handling for unique constraint (#1567)

This commit is contained in:
Michael Victor Zink 2024-12-03 17:09:00 -08:00 committed by GitHub
parent 6d4188de53
commit 6517da6b7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 71 additions and 4 deletions

View file

@ -594,6 +594,25 @@ fn parse_alter_table_constraints_rename() {
}
}
#[test]
fn parse_alter_table_constraints_unique_nulls_distinct() {
match pg_and_generic()
.verified_stmt("ALTER TABLE t ADD CONSTRAINT b UNIQUE NULLS NOT DISTINCT (c)")
{
Statement::AlterTable { operations, .. } => match &operations[0] {
AlterTableOperation::AddConstraint(TableConstraint::Unique {
nulls_distinct, ..
}) => {
assert_eq!(nulls_distinct, &NullsDistinctOption::NotDistinct)
}
_ => unreachable!(),
},
_ => unreachable!(),
}
pg_and_generic().verified_stmt("ALTER TABLE t ADD CONSTRAINT b UNIQUE NULLS DISTINCT (c)");
pg_and_generic().verified_stmt("ALTER TABLE t ADD CONSTRAINT b UNIQUE (c)");
}
#[test]
fn parse_alter_table_disable() {
pg_and_generic().verified_stmt("ALTER TABLE tab DISABLE ROW LEVEL SECURITY");