@@ -524,9 +524,9 @@ public void testIdempotentTableOperations() throws Exception {
524524 @ Test
525525 public void testIdempotentAddColumnOperations () throws Exception {
526526 String addColumnStmt = switch (dbms .getDbType ()) {
527- case "oracle" -> "alter table TEST_C add (NEW_COL integer);" ;
528- case "mssql" -> "alter table TEST_C add NEW_COL int;" ;
529- default -> "alter table TEST_C add column NEW_COL int;" ;
527+ case "oracle" -> "alter table TEST_C add (NEW_COL integer);" ;
528+ case "mssql" -> "alter table TEST_C add NEW_COL int;" ;
529+ default -> "alter table TEST_C add column NEW_COL int;" ;
530530 };
531531 String [] addScripts = new String []{
532532 "create table TEST_C (ID int);" ,
@@ -546,10 +546,9 @@ public void testIdempotentIndexOperations() throws Exception {
546546 "create index TEST_IDX on TEST_D (ID);"
547547 };
548548 String dropIndexStmt = switch (dbms .getDbType ()) {
549- case "derby" -> "drop index \" APP\" .\" TEST_IDX\" ;" ;
550- case "oracle" ,
551- "postgres" -> "drop index TEST_IDX;" ;
552- default -> "drop index TEST_IDX on TEST_D;" ;
549+ case "derby" -> "drop index \" APP\" .\" TEST_IDX\" ;" ;
550+ case "oracle" , "postgres" -> "drop index TEST_IDX;" ;
551+ default -> "drop index TEST_IDX on TEST_D;" ;
553552 };
554553 String [] dropScripts = new String []{dropIndexStmt };
555554 executeWithIdempotencyCheck ("IndexOperations-create" , createScripts );
@@ -561,37 +560,37 @@ public void testIdempotentConstraintOperations() throws Exception {
561560 String [] createScripts ;
562561 String [] dropScripts ;
563562 switch (dbms .getDbType ()) {
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- "alter table TEST_E drop constraint TEST_E_FK;" ,
583- "alter table TEST_E drop constraint TEST_E_UQ;"
584- };
585- }
586- default -> {
587- createScripts = new String []{
588- "create table TEST_E (ID int, VAL int);" ,
589- "alter table TEST_E add constraint TEST_E_UQ unique (ID);"
590- };
591- dropScripts = new String []{
592- "alter table TEST_E drop constraint TEST_E_UQ;"
593- };
594- }
563+ case "mysql" -> {
564+ createScripts = new String [] {
565+ "create table TEST_E (ID int primary key, FK_COL int, "
566+ + "constraint TEST_E_FK foreign key (FK_COL) references TEST_E(ID));"
567+ };
568+ dropScripts = new String [] {
569+ "alter table TEST_E drop foreign key TEST_E_FK;" ,
570+ "alter table TEST_E drop key TEST_E_FK;" ,
571+ "alter table TEST_E drop column FK_COL;"
572+ };
573+ }
574+ case "mssql" -> {
575+ createScripts = new String [] {
576+ "create table TEST_E (ID int primary key, FK_COL int, VAL int);" ,
577+ "alter table TEST_E add constraint TEST_E_UQ unique (VAL);" ,
578+ "alter table TEST_E add constraint TEST_E_FK foreign key (FK_COL) references TEST_E(ID);"
579+ };
580+ dropScripts = new String [] {
581+ "alter table TEST_E drop constraint TEST_E_FK;" ,
582+ "alter table TEST_E drop constraint TEST_E_UQ;"
583+ };
584+ }
585+ default -> {
586+ createScripts = new String [] {
587+ "create table TEST_E (ID int, VAL int);" ,
588+ "alter table TEST_E add constraint TEST_E_UQ unique (ID);"
589+ };
590+ dropScripts = new String [] {
591+ "alter table TEST_E drop constraint TEST_E_UQ;"
592+ };
593+ }
595594 }
596595 executeWithIdempotencyCheck ("ConstraintOperations-add" , createScripts );
597596 executeWithIdempotencyCheck ("ConstraintOperations-drop" , dropScripts );
@@ -607,35 +606,35 @@ public void testIdempotentAlterColumnOperations() throws Exception {
607606 String [] alterScripts ;
608607 String [] dropScripts = new String []{"alter table TEST_F drop column COL_RENAMED;" };
609608 switch (dbms .getDbType ()) {
610- case "derby" -> {
611- alterScripts = new String []{
612- "create table \" TEST_F\" (\" ID\" int, \" COL_MOD\" varchar(10), \" COL_RENAME\" varchar(10));" ,
613- "alter table \" TEST_F\" alter \" COL_MOD\" set data type varchar(50);" ,
614- "rename column \" APP\" .\" TEST_F\" .\" COL_RENAME\" to \" COL_RENAMED\" ;"
615- };
616- dropScripts = new String []{"alter table \" TEST_F\" drop column \" COL_RENAMED\" ;" };
617- }
618- case "mssql" -> alterScripts = new String []{
619- "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
620- "alter table TEST_F alter column COL_MOD varchar(50) not null;" ,
621- "exec sp_rename 'TEST_F.COL_RENAME', 'COL_RENAMED', 'COLUMN';"
622- };
623- case "oracle" -> alterScripts = new String []{
624- "create table TEST_F (ID integer, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
625- "alter table TEST_F modify (COL_MOD varchar(50));" ,
626- "alter table TEST_F rename column COL_RENAME to COL_RENAMED;"
627- };
628- case "postgres" -> alterScripts = new String []{
629- "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
630- "alter table TEST_F alter column COL_MOD type varchar(50);" ,
631- "alter table TEST_F rename column COL_RENAME to COL_RENAMED;"
609+ case "derby" -> {
610+ alterScripts = new String [] {
611+ "create table \" TEST_F\" (\" ID\" int, \" COL_MOD\" varchar(10), \" COL_RENAME\" varchar(10));" ,
612+ "alter table \" TEST_F\" alter \" COL_MOD\" set data type varchar(50);" ,
613+ "rename column \" APP\" .\" TEST_F\" .\" COL_RENAME\" to \" COL_RENAMED\" ;"
632614 };
633- default -> // mysql: CHANGE COLUMN renames and redefines in one statement
634- alterScripts = new String []{
635- "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
636- "alter table TEST_F modify column COL_MOD varchar(50);" ,
637- "alter table TEST_F change column COL_RENAME COL_RENAMED varchar(10);"
638- };
615+ dropScripts = new String [] {"alter table \" TEST_F\" drop column \" COL_RENAMED\" ;" };
616+ }
617+ case "mssql" -> alterScripts = new String [] {
618+ "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
619+ "alter table TEST_F alter column COL_MOD varchar(50) not null;" ,
620+ "exec sp_rename 'TEST_F.COL_RENAME', 'COL_RENAMED', 'COLUMN';"
621+ };
622+ case "oracle" -> alterScripts = new String [] {
623+ "create table TEST_F (ID integer, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
624+ "alter table TEST_F modify (COL_MOD varchar(50));" ,
625+ "alter table TEST_F rename column COL_RENAME to COL_RENAMED;"
626+ };
627+ case "postgres" -> alterScripts = new String [] {
628+ "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
629+ "alter table TEST_F alter column COL_MOD type varchar(50);" ,
630+ "alter table TEST_F rename column COL_RENAME to COL_RENAMED;"
631+ };
632+ default -> // mysql: CHANGE COLUMN renames and redefines in one statement
633+ alterScripts = new String [] {
634+ "create table TEST_F (ID int, COL_MOD varchar(10), COL_RENAME varchar(10));" ,
635+ "alter table TEST_F modify column COL_MOD varchar(50);" ,
636+ "alter table TEST_F change column COL_RENAME COL_RENAMED varchar(10);"
637+ };
639638 }
640639 executeWithIdempotencyCheck ("AlterColumnOperations-alter" , alterScripts );
641640 executeWithIdempotencyCheck ("AlterColumnOperations-drop" , dropScripts );
0 commit comments