]> source.dussan.org Git - sonarqube.git/commitdiff
fix type of INTEGER columns on Oracle
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 13 Dec 2016 12:52:23 +0000 (13:52 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 13 Dec 2016 12:52:35 +0000 (13:52 +0100)
Correct type is NUMBER(38,0) but not INTEGER

Signed-off-by: Simon Brandhof <simon.brandhof@sonarsource.com>
sonar-db/src/main/java/org/sonar/db/version/IntegerColumnDef.java
sonar-db/src/test/java/org/sonar/db/version/CreateTableBuilderTest.java
sonar-db/src/test/java/org/sonar/db/version/IntegerColumnDefTest.java

index 8b41a8a4ed8cb52c72b1c1994d60f65706e060e9..6a75b6859b1ab4a15900afb2d3394b8cdb8982fe 100644 (file)
@@ -43,12 +43,13 @@ public class IntegerColumnDef extends AbstractColumnDef {
   public String generateSqlType(Dialect dialect) {
     switch (dialect.getId()) {
       case PostgreSql.ID:
-      case Oracle.ID:
       case MySql.ID:
       case H2.ID:
         return "INTEGER";
       case MsSql.ID:
         return "INT";
+      case Oracle.ID:
+        return "NUMBER(38,0)";
       default:
         throw new IllegalArgumentException("Unsupported dialect id " + dialect.getId());
     }
index 2b11ff4eb89ff82f022f42650c9a7b20f22e2a6d..3f8958d884ca65c12ef162bccbf87e250ec1f2ad 100644 (file)
@@ -253,7 +253,7 @@ public class CreateTableBuilderTest {
       .build();
     assertThat(stmts).hasSize(3);
     assertThat(stmts.get(0))
-      .isEqualTo("CREATE TABLE table_42 (id INTEGER NOT NULL, CONSTRAINT pk_table_42 PRIMARY KEY (id))");
+      .isEqualTo("CREATE TABLE table_42 (id NUMBER(38,0) NOT NULL, CONSTRAINT pk_table_42 PRIMARY KEY (id))");
     assertThat(stmts.get(1))
       .isEqualTo("CREATE SEQUENCE table_42_seq START WITH 1 INCREMENT BY 1");
     assertThat(stmts.get(2))
index 935fb96cfd8948b41253ec211712de78dad181e2..556dba13768b80e9ad2c87db9c5fcf264c96a91d 100644 (file)
@@ -87,7 +87,7 @@ public class IntegerColumnDefTest {
 
   @Test
   public void generateSqlType_for_Oracle() {
-    assertThat(underTest.generateSqlType(new Oracle())).isEqualTo("INTEGER");
+    assertThat(underTest.generateSqlType(new Oracle())).isEqualTo("NUMBER(38,0)");
   }
 
   @Test