@@ -200,17 +200,18 @@ pub enum AlterTableOperation {
200200 } ,
201201 /// `DROP PRIMARY KEY`
202202 ///
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+ } ,
207208 /// `DROP FOREIGN KEY <fk_symbol>`
208209 ///
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)
212212 DropForeignKey {
213213 name : Ident ,
214+ drop_behavior : Option < DropBehavior > ,
214215 } ,
215216 /// `DROP INDEX <index_name>`
216217 ///
@@ -648,36 +649,51 @@ impl fmt::Display for AlterTableOperation {
648649 } => {
649650 write ! (
650651 f,
651- "DROP CONSTRAINT {}{}{} " ,
652+ "DROP CONSTRAINT {}{}" ,
652653 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 ( ( ) )
660677 }
661- AlterTableOperation :: DropPrimaryKey => write ! ( f, "DROP PRIMARY KEY" ) ,
662- AlterTableOperation :: DropForeignKey { name } => write ! ( f, "DROP FOREIGN KEY {name}" ) ,
663678 AlterTableOperation :: DropIndex { name } => write ! ( f, "DROP INDEX {name}" ) ,
664679 AlterTableOperation :: DropColumn {
665680 has_column_keyword,
666681 column_names : column_name,
667682 if_exists,
668683 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}" ) ? ;
679694 }
680- ) ,
695+ Ok ( ( ) )
696+ }
681697 AlterTableOperation :: AttachPartition { partition } => {
682698 write ! ( f, "ATTACH {partition}" )
683699 }
0 commit comments