@@ -272,6 +272,33 @@ void dropColumnActionDoesNotBecomeAPrimaryKeyDeclarationFromStaleFields() throws
272272 assertEquals (before , action .toString ());
273273 }
274274
275+ @ ParameterizedTest
276+ @ ValueSource (strings = {"DROP PRIMARY KEY" , "DROP FOREIGN KEY fk" , "DROP CHECK ck" })
277+ void distinguishesBaseRenamePrecedenceFromSpecializedDropRendering (String sql )
278+ throws Exception {
279+ AlterExpression drop = action ("ALTER TABLE t " + sql , Dialect .MYSQL );
280+ Kind expected = drop .getConstraintKind ();
281+ String before = drop .toString ();
282+ Index oldName = new Index ().withName ("old_name" );
283+ Index newName = new Index ().withName ("new_name" );
284+ drop .setOldIndex (oldName );
285+ drop .setIndex (newName );
286+ assertEquals (expected , drop .getConstraintKind ());
287+ assertEquals (before , drop .toString ());
288+
289+ AlterExpression base = new AlterExpression ().withOperation (drop .getOperation ());
290+ base .setOldIndex (oldName );
291+ base .setIndex (newName );
292+ assertTrue (base .toString ().startsWith ("RENAME" ));
293+ assertEquals (Kind .OTHER , base .getConstraintKind ());
294+
295+ base .setOperation (AlterOperation .ALTER );
296+ base .setConstraintType ("CHECK" );
297+ base .setConstraintSymbol ("ck" );
298+ assertTrue (base .toString ().startsWith ("ALTER CHECK ck" ));
299+ assertEquals (Kind .CHECK , base .getConstraintKind ());
300+ }
301+
275302 @ Test
276303 void supportsLegacyOnlyKeysWithoutMistakingDropColumnsForPrimaryKeys () {
277304 AlterExpression legacy = new AlterExpression ().withOperation (AlterOperation .ADD )
0 commit comments