Skip to content

Commit 402ef42

Browse files
Update tests/sqlparser_postgres.rs
Co-authored-by: Ifeanyi Ubah <[email protected]>
1 parent 330e626 commit 402ef42

File tree

1 file changed

+1
-32
lines changed

1 file changed

+1
-32
lines changed

tests/sqlparser_postgres.rs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6749,36 +6749,5 @@ fn parse_foreign_key_match_partial() {
67496749
fn parse_foreign_key_match_with_actions() {
67506750
let sql = "CREATE TABLE orders (order_id INT REFERENCES another_table (id) MATCH FULL ON DELETE CASCADE ON UPDATE RESTRICT, customer_id INT, CONSTRAINT fk_customer FOREIGN KEY (customer_id) REFERENCES customers(customer_id) MATCH SIMPLE ON DELETE SET NULL ON UPDATE CASCADE)";
67516751

6752-
let statement = pg_and_generic().verified_stmt(sql);
6753-
match statement {
6754-
Statement::CreateTable(CreateTable {
6755-
columns,
6756-
constraints,
6757-
..
6758-
}) => {
6759-
// Check column-level foreign key with MATCH FULL and actions
6760-
match &columns[0].options[0].option {
6761-
ColumnOption::ForeignKey(constraint) => {
6762-
assert_eq!(constraint.foreign_table.to_string(), "another_table");
6763-
assert_eq!(constraint.match_kind, Some(MatchKind::Full));
6764-
assert_eq!(constraint.on_delete, Some(ReferentialAction::Cascade));
6765-
assert_eq!(constraint.on_update, Some(ReferentialAction::Restrict));
6766-
}
6767-
_ => panic!("Expected ColumnOption::ForeignKey"),
6768-
}
6769-
6770-
// Check table-level foreign key constraint with MATCH SIMPLE and actions
6771-
match &constraints[0] {
6772-
TableConstraint::ForeignKey(constraint) => {
6773-
assert_eq!(constraint.name.as_ref().unwrap().value, "fk_customer");
6774-
assert_eq!(constraint.foreign_table.to_string(), "customers");
6775-
assert_eq!(constraint.match_kind, Some(MatchKind::Simple));
6776-
assert_eq!(constraint.on_delete, Some(ReferentialAction::SetNull));
6777-
assert_eq!(constraint.on_update, Some(ReferentialAction::Cascade));
6778-
}
6779-
_ => panic!("Expected TableConstraint::ForeignKey"),
6780-
}
6781-
}
6782-
_ => unreachable!("{:?} should parse to Statement::CreateTable", sql),
6783-
}
6752+
pg_and_generic().verified_stmt(sql);
67846753
}

0 commit comments

Comments
 (0)