From: Simon Brandhof Date: Tue, 22 Aug 2017 15:33:27 +0000 (+0200) Subject: Use VARCHAR2 on Oracle instead of VARCHAR X-Git-Tag: 6.6-RC1~542 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=71291b751aed27c2b62effcd2852e5e89dd4a9e9;p=sonarqube.git Use VARCHAR2 on Oracle instead of VARCHAR The type VARCHAR has been badly introduced when implementing the Java DB migration tool. Keeping VARCHAR on some installations should not be a problem. A fix will be done if needed. --- diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/def/VarcharColumnDef.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/def/VarcharColumnDef.java index be650c124d8..c882054d5bb 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/def/VarcharColumnDef.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/def/VarcharColumnDef.java @@ -66,7 +66,7 @@ public class VarcharColumnDef extends AbstractColumnDef { case MsSql.ID: return format("NVARCHAR (%d)", columnSize); case Oracle.ID: - return format("VARCHAR (%d%s)", columnSize, ignoreOracleUnit ? "" : " CHAR"); + return format("VARCHAR2 (%d%s)", columnSize, ignoreOracleUnit ? "" : " CHAR"); default: return format("VARCHAR (%d)", columnSize); } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/VarcharColumnDefTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/VarcharColumnDefTest.java index 63f1e304dc8..e2f5f3de0b3 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/VarcharColumnDefTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/VarcharColumnDefTest.java @@ -75,7 +75,7 @@ public class VarcharColumnDefTest { assertThat(def.generateSqlType(new PostgreSql())).isEqualTo("VARCHAR (10)"); assertThat(def.generateSqlType(new MySql())).isEqualTo("VARCHAR (10)"); assertThat(def.generateSqlType(new MsSql())).isEqualTo("NVARCHAR (10)"); - assertThat(def.generateSqlType(new Oracle())).isEqualTo("VARCHAR (10 CHAR)"); + assertThat(def.generateSqlType(new Oracle())).isEqualTo("VARCHAR2 (10 CHAR)"); } @Test @@ -87,7 +87,7 @@ public class VarcharColumnDefTest { .setIgnoreOracleUnit(true) .build(); - assertThat(def.generateSqlType(new Oracle())).isEqualTo("VARCHAR (10)"); + assertThat(def.generateSqlType(new Oracle())).isEqualTo("VARCHAR2 (10)"); } @Test diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AddColumnsBuilderTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AddColumnsBuilderTest.java index bc4603ee820..6a0278dae67 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AddColumnsBuilderTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AddColumnsBuilderTest.java @@ -57,7 +57,7 @@ public class AddColumnsBuilderTest { @Test public void add_columns_on_oracle() { assertThat(createSampleBuilder(new Oracle()).build()) - .isEqualTo("ALTER TABLE issues ADD (date_in_ms NUMBER (38) NULL, name VARCHAR (10 CHAR) NOT NULL, col_with_default NUMBER(1) DEFAULT 0 NOT NULL, varchar_col_with_default VARCHAR (3 CHAR) DEFAULT 'foo' NOT NULL)"); + .isEqualTo("ALTER TABLE issues ADD (date_in_ms NUMBER (38) NULL, name VARCHAR2 (10 CHAR) NOT NULL, col_with_default NUMBER(1) DEFAULT 0 NOT NULL, varchar_col_with_default VARCHAR2 (3 CHAR) DEFAULT 'foo' NOT NULL)"); } @Test diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AlterColumnsBuilderTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AlterColumnsBuilderTest.java index 5a789715989..617c7f0802e 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AlterColumnsBuilderTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AlterColumnsBuilderTest.java @@ -100,13 +100,13 @@ public class AlterColumnsBuilderTest { assertThat(createSampleBuilder(new Oracle()).build()) .containsOnly( "ALTER TABLE issues MODIFY (value NUMERIC (30,20) NULL)", - "ALTER TABLE issues MODIFY (name VARCHAR (10 CHAR) NULL)"); + "ALTER TABLE issues MODIFY (name VARCHAR2 (10 CHAR) NULL)"); } @Test public void update_not_nullable_column_on_oracle() { assertThat(createNotNullableBuilder(new Oracle()).build()) - .containsOnly("ALTER TABLE issues MODIFY (name VARCHAR (10 CHAR) NOT NULL)"); + .containsOnly("ALTER TABLE issues MODIFY (name VARCHAR2 (10 CHAR) NOT NULL)"); } @Test diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderTest.java index 15882c6ce43..4e7627ec881 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderTest.java @@ -528,7 +528,7 @@ public class CreateTableBuilderTest { @Test public void build_adds_DEFAULT_clause_on_varchar_column_on_Oracle() { - verifyDefaultClauseOnVarcharColumn(ORACLE, "CREATE TABLE table_42 (status VARCHAR (1 CHAR) DEFAULT 'P' NOT NULL)"); + verifyDefaultClauseOnVarcharColumn(ORACLE, "CREATE TABLE table_42 (status VARCHAR2 (1 CHAR) DEFAULT 'P' NOT NULL)"); } @Test