File tree 3 files changed +6
-3
lines changed
3 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -885,12 +885,14 @@ impl fmt::Display for TableConstraint {
885
885
} => {
886
886
write ! (
887
887
f,
888
- "{}FOREIGN KEY ({}) REFERENCES {}({}) " ,
888
+ "{}FOREIGN KEY ({}) REFERENCES {}" ,
889
889
display_constraint_name( name) ,
890
890
display_comma_separated( columns) ,
891
891
foreign_table,
892
- display_comma_separated( referred_columns) ,
893
892
) ?;
893
+ if !referred_columns. is_empty ( ) {
894
+ write ! ( f, "({})" , display_comma_separated( referred_columns) ) ?;
895
+ }
894
896
if let Some ( action) = on_delete {
895
897
write ! ( f, " ON DELETE {action}" ) ?;
896
898
}
Original file line number Diff line number Diff line change @@ -6830,7 +6830,7 @@ impl<'a> Parser<'a> {
6830
6830
let columns = self.parse_parenthesized_column_list(Mandatory, false)?;
6831
6831
self.expect_keyword(Keyword::REFERENCES)?;
6832
6832
let foreign_table = self.parse_object_name(false)?;
6833
- let referred_columns = self.parse_parenthesized_column_list(Mandatory , false)?;
6833
+ let referred_columns = self.parse_parenthesized_column_list(Optional , false)?;
6834
6834
let mut on_delete = None;
6835
6835
let mut on_update = None;
6836
6836
loop {
Original file line number Diff line number Diff line change @@ -4167,6 +4167,7 @@ fn parse_alter_table_constraints() {
4167
4167
check_one ( "UNIQUE (id)" ) ;
4168
4168
check_one ( "FOREIGN KEY (foo, bar) REFERENCES AnotherTable(foo, bar)" ) ;
4169
4169
check_one ( "CHECK (end_date > start_date OR end_date IS NULL)" ) ;
4170
+ check_one ( "CONSTRAINT fk FOREIGN KEY (lng) REFERENCES othertable4" ) ;
4170
4171
4171
4172
fn check_one ( constraint_text : & str ) {
4172
4173
match alter_table_op ( verified_stmt ( & format ! (
You can’t perform that action at this time.
0 commit comments