@@ -525,9 +525,9 @@ public void testIdempotentTableOperations() throws Exception {
525525 @ Test
526526 public void testIdempotentAddColumnOperations () throws Exception {
527527 String addColumnStmt = switch (dbms .getDbType ()) {
528- case "oracle" -> "alter table TEST_C add (NEW_COL integer);" ;
529- case "mssql" -> "alter table TEST_C add NEW_COL int;" ;
530- default -> "alter table TEST_C add column NEW_COL int;" ;
528+ case "oracle" -> "alter table TEST_C add (NEW_COL integer);" ;
529+ case "mssql" -> "alter table TEST_C add NEW_COL int;" ;
530+ default -> "alter table TEST_C add column NEW_COL int;" ;
531531 };
532532 String [] addScripts = new String []{
533533 "create table TEST_C (ID int);" ,
@@ -547,10 +547,9 @@ public void testIdempotentIndexOperations() throws Exception {
547547 "create index TEST_IDX on TEST_D (ID);"
548548 };
549549 String dropIndexStmt = switch (dbms .getDbType ()) {
550- case "derby" -> "drop index \" APP\" .\" TEST_IDX\" ;" ;
551- case "oracle" ,
552- "postgres" -> "drop index TEST_IDX;" ;
553- default -> "drop index TEST_IDX on TEST_D;" ;
550+ case "derby" -> "drop index \" APP\" .\" TEST_IDX\" ;" ;
551+ case "oracle" , "postgres" -> "drop index TEST_IDX;" ;
552+ default -> "drop index TEST_IDX on TEST_D;" ;
554553 };
555554 String [] dropScripts = new String []{dropIndexStmt };
556555 executeWithIdempotencyCheck ("IndexOperations-create" , createScripts );
@@ -562,38 +561,38 @@ public void testIdempotentConstraintOperations() throws Exception {
562561 String [] createScripts ;
563562 String [] dropScripts ;
564563 switch (dbms .getDbType ()) {
565- case "mysql" -> {
566- createScripts = new String []{
567- "create table TEST_E (ID int primary key, FK_COL int, "
568- + "constraint TEST_E_FK foreign key (FK_COL) references TEST_E(ID));"
569- };
570- dropScripts = new String []{
571- "alter table TEST_E drop foreign key TEST_E_FK;" ,
572- "alter table TEST_E drop key TEST_E_FK;" ,
573- "alter table TEST_E drop column FK_COL;"
574- };
575- }
576- case "mssql" -> {
577- createScripts = new String []{
578- "create table TEST_E (ID int primary key, FK_COL int, VAL int);" ,
579- "alter table TEST_E add constraint TEST_E_UQ unique (VAL);" ,
580- "alter table TEST_E add constraint TEST_E_FK foreign key (FK_COL) references TEST_E(ID);"
581- };
582- dropScripts = new String []{
583- "create procedure #DROP_FK_HELPER as begin alter table TEST_E drop constraint TEST_E_FK end;" ,
564+ case "mysql" -> {
565+ createScripts = new String [] {
566+ "create table TEST_E (ID int primary key, FK_COL int, "
567+ + "constraint TEST_E_FK foreign key (FK_COL) references TEST_E(ID));"
568+ };
569+ dropScripts = new String [] {
570+ "alter table TEST_E drop foreign key TEST_E_FK;" ,
571+ "alter table TEST_E drop key TEST_E_FK;" ,
572+ "alter table TEST_E drop column FK_COL;"
573+ };
574+ }
575+ case "mssql" -> {
576+ createScripts = new String [] {
577+ "create table TEST_E (ID int primary key, FK_COL int, VAL int);" ,
578+ "alter table TEST_E add constraint TEST_E_UQ unique (VAL);" ,
579+ "alter table TEST_E add constraint TEST_E_FK foreign key (FK_COL) references TEST_E(ID);"
580+ };
581+ dropScripts = new String [] {
582+ "create procedure #DROP_FK_HELPER as begin alter table TEST_E drop constraint TEST_E_FK end;" ,
584583 "exec #DROP_FK_HELPER;" ,
585- "alter table TEST_E drop constraint TEST_E_UQ;"
586- };
587- }
588- default -> {
589- createScripts = new String []{
590- "create table TEST_E (ID int, VAL int);" ,
591- "alter table TEST_E add constraint TEST_E_UQ unique (ID);"
592- };
593- dropScripts = new String []{
594- "alter table TEST_E drop constraint TEST_E_UQ;"
595- };
596- }
584+ "alter table TEST_E drop constraint TEST_E_UQ;"
585+ };
586+ }
587+ default -> {
588+ createScripts = new String [] {
589+ "create table TEST_E (ID int, VAL int);" ,
590+ "alter table TEST_E add constraint TEST_E_UQ unique (ID);"
591+ };
592+ dropScripts = new String [] {
593+ "alter table TEST_E drop constraint TEST_E_UQ;"
594+ };
595+ }
597596 }
598597 executeWithIdempotencyCheck ("ConstraintOperations-add" , createScripts );
599598 executeWithIdempotencyCheck ("ConstraintOperations-drop" , dropScripts );
@@ -609,35 +608,35 @@ public void testIdempotentAlterColumnOperations() throws Exception {
609608 String [] alterScripts ;
610609 String [] dropScripts = new String []{"alter table TEST_F drop column COL_RENAMED;" };
611610 switch (dbms .getDbType ()) {
612- case "derby" -> {
613- alterScripts = new String []{
614- "create table \" TEST_F\" (\" ID\" int, \" COL_MOD\" varchar(10), \" COL_RENAME\" varchar(10));" ,
615- "alter table \" TEST_F\" alter \" COL_MOD\" set data type varchar(50);" ,
616- "rename column \" APP\" .\" TEST_F\" .\" COL_RENAME\" to \" COL_RENAMED\" ;"
617- };
618- dropScripts = new String []{"alter table \" TEST_F\" drop column \" COL_RENAMED\" ;" };
619- }
620- case "mssql" -> alterScripts = new String []{
621- "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
622- "alter table TEST_F alter column COL_MOD varchar(50) not null;" ,
623- "exec sp_rename 'TEST_F.COL_RENAME', 'COL_RENAMED', 'COLUMN';"
624- };
625- case "oracle" -> alterScripts = new String []{
626- "create table TEST_F (ID integer, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
627- "alter table TEST_F modify (COL_MOD varchar(50));" ,
628- "alter table TEST_F rename column COL_RENAME to COL_RENAMED;"
629- };
630- case "postgres" -> alterScripts = new String []{
631- "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
632- "alter table TEST_F alter column COL_MOD type varchar(50);" ,
633- "alter table TEST_F rename column COL_RENAME to COL_RENAMED;"
611+ case "derby" -> {
612+ alterScripts = new String [] {
613+ "create table \" TEST_F\" (\" ID\" int, \" COL_MOD\" varchar(10), \" COL_RENAME\" varchar(10));" ,
614+ "alter table \" TEST_F\" alter \" COL_MOD\" set data type varchar(50);" ,
615+ "rename column \" APP\" .\" TEST_F\" .\" COL_RENAME\" to \" COL_RENAMED\" ;"
634616 };
635- default -> // mysql: CHANGE COLUMN renames and redefines in one statement
636- alterScripts = new String []{
637- "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
638- "alter table TEST_F modify column COL_MOD varchar(50);" ,
639- "alter table TEST_F change column COL_RENAME COL_RENAMED varchar(10);"
640- };
617+ dropScripts = new String [] {"alter table \" TEST_F\" drop column \" COL_RENAMED\" ;" };
618+ }
619+ case "mssql" -> alterScripts = new String [] {
620+ "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
621+ "alter table TEST_F alter column COL_MOD varchar(50) not null;" ,
622+ "exec sp_rename 'TEST_F.COL_RENAME', 'COL_RENAMED', 'COLUMN';"
623+ };
624+ case "oracle" -> alterScripts = new String [] {
625+ "create table TEST_F (ID integer, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
626+ "alter table TEST_F modify (COL_MOD varchar(50));" ,
627+ "alter table TEST_F rename column COL_RENAME to COL_RENAMED;"
628+ };
629+ case "postgres" -> alterScripts = new String [] {
630+ "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
631+ "alter table TEST_F alter column COL_MOD type varchar(50);" ,
632+ "alter table TEST_F rename column COL_RENAME to COL_RENAMED;"
633+ };
634+ default -> // mysql: CHANGE COLUMN renames and redefines in one statement
635+ alterScripts = new String [] {
636+ "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
637+ "alter table TEST_F modify column COL_MOD varchar(50);" ,
638+ "alter table TEST_F change column COL_RENAME COL_RENAMED varchar(10);"
639+ };
641640 }
642641 executeWithIdempotencyCheck ("AlterColumnOperations-alter" , alterScripts );
643642 executeWithIdempotencyCheck ("AlterColumnOperations-drop" , dropScripts );
0 commit comments