@@ -200,17 +200,18 @@ pub enum AlterTableOperation {
200
200
} ,
201
201
/// `DROP PRIMARY KEY`
202
202
///
203
- /// Note: this is a [MySQL]-specific operation.
204
- ///
205
- /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html
206
- DropPrimaryKey ,
203
+ /// [MySQL](https://dev.mysql.com/doc/refman/8.4/en/alter-table.html)
204
+ /// [Snowflake](https://docs.snowflake.com/en/sql-reference/constraints-drop)
205
+ DropPrimaryKey {
206
+ drop_behavior : Option < DropBehavior > ,
207
+ } ,
207
208
/// `DROP FOREIGN KEY <fk_symbol>`
208
209
///
209
- /// Note: this is a [MySQL]-specific operation.
210
- ///
211
- /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html
210
+ /// [MySQL](https://dev.mysql.com/doc/refman/8.4/en/alter-table.html)
211
+ /// [Snowflake](https://docs.snowflake.com/en/sql-reference/constraints-drop)
212
212
DropForeignKey {
213
213
name : Ident ,
214
+ drop_behavior : Option < DropBehavior > ,
214
215
} ,
215
216
/// `DROP INDEX <index_name>`
216
217
///
@@ -648,36 +649,51 @@ impl fmt::Display for AlterTableOperation {
648
649
} => {
649
650
write ! (
650
651
f,
651
- "DROP CONSTRAINT {}{}{} " ,
652
+ "DROP CONSTRAINT {}{}" ,
652
653
if * if_exists { "IF EXISTS " } else { "" } ,
653
- name,
654
- match drop_behavior {
655
- None => "" ,
656
- Some ( DropBehavior :: Restrict ) => " RESTRICT" ,
657
- Some ( DropBehavior :: Cascade ) => " CASCADE" ,
658
- }
659
- )
654
+ name
655
+ ) ?;
656
+ if let Some ( drop_behavior) = drop_behavior {
657
+ write ! ( f, " {drop_behavior}" ) ?;
658
+ }
659
+ Ok ( ( ) )
660
+ }
661
+ AlterTableOperation :: DropPrimaryKey { drop_behavior } => {
662
+ write ! ( f, "DROP PRIMARY KEY" ) ?;
663
+ if let Some ( drop_behavior) = drop_behavior {
664
+ write ! ( f, " {drop_behavior}" ) ?;
665
+ }
666
+ Ok ( ( ) )
667
+ }
668
+ AlterTableOperation :: DropForeignKey {
669
+ name,
670
+ drop_behavior,
671
+ } => {
672
+ write ! ( f, "DROP FOREIGN KEY {name}" ) ?;
673
+ if let Some ( drop_behavior) = drop_behavior {
674
+ write ! ( f, " {drop_behavior}" ) ?;
675
+ }
676
+ Ok ( ( ) )
660
677
}
661
- AlterTableOperation :: DropPrimaryKey => write ! ( f, "DROP PRIMARY KEY" ) ,
662
- AlterTableOperation :: DropForeignKey { name } => write ! ( f, "DROP FOREIGN KEY {name}" ) ,
663
678
AlterTableOperation :: DropIndex { name } => write ! ( f, "DROP INDEX {name}" ) ,
664
679
AlterTableOperation :: DropColumn {
665
680
has_column_keyword,
666
681
column_names : column_name,
667
682
if_exists,
668
683
drop_behavior,
669
- } => write ! (
670
- f ,
671
- "DROP {}{}{}{}" ,
672
- if * has_column_keyword { "COLUMN " } else { "" } ,
673
- if * if_exists { "IF EXISTS " } else { "" } ,
674
- display_comma_separated ( column_name ) ,
675
- match drop_behavior {
676
- None => "" ,
677
- Some ( DropBehavior :: Restrict ) => " RESTRICT" ,
678
- Some ( DropBehavior :: Cascade ) => " CASCADE" ,
684
+ } => {
685
+ write ! (
686
+ f ,
687
+ "DROP {}{}{}" ,
688
+ if * has_column_keyword { "COLUMN " } else { "" } ,
689
+ if * if_exists { "IF EXISTS " } else { "" } ,
690
+ display_comma_separated ( column_name ) ,
691
+ ) ? ;
692
+ if let Some ( drop_behavior ) = drop_behavior {
693
+ write ! ( f , " {drop_behavior}" ) ? ;
679
694
}
680
- ) ,
695
+ Ok ( ( ) )
696
+ }
681
697
AlterTableOperation :: AttachPartition { partition } => {
682
698
write ! ( f, "ATTACH {partition}" )
683
699
}
0 commit comments