aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-migration
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-08-22 17:33:27 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-08-24 11:54:24 +0200
commit71291b751aed27c2b62effcd2852e5e89dd4a9e9 (patch)
treebbfad2d00f38bd09018e39ed5699b9352291e2b6 /server/sonar-db-migration
parent227e8f9108ff18ea7049dfbc57ee2ca4f81b405a (diff)
downloadsonarqube-71291b751aed27c2b62effcd2852e5e89dd4a9e9.tar.gz
sonarqube-71291b751aed27c2b62effcd2852e5e89dd4a9e9.zip
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.
Diffstat (limited to 'server/sonar-db-migration')
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/def/VarcharColumnDef.java2
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/def/VarcharColumnDefTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AddColumnsBuilderTest.java2
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AlterColumnsBuilderTest.java4
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderTest.java2
5 files changed, 7 insertions, 7 deletions
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