From 31ee668ab9f8ed0c998278ceaae422ef91f1b5bf Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 13 Dec 2016 13:52:23 +0100 Subject: [PATCH] fix type of INTEGER columns on Oracle Correct type is NUMBER(38,0) but not INTEGER Signed-off-by: Simon Brandhof --- .../src/main/java/org/sonar/db/version/IntegerColumnDef.java | 3 ++- .../test/java/org/sonar/db/version/CreateTableBuilderTest.java | 2 +- .../test/java/org/sonar/db/version/IntegerColumnDefTest.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sonar-db/src/main/java/org/sonar/db/version/IntegerColumnDef.java b/sonar-db/src/main/java/org/sonar/db/version/IntegerColumnDef.java index 8b41a8a4ed8..6a75b6859b1 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/IntegerColumnDef.java +++ b/sonar-db/src/main/java/org/sonar/db/version/IntegerColumnDef.java @@ -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()); } diff --git a/sonar-db/src/test/java/org/sonar/db/version/CreateTableBuilderTest.java b/sonar-db/src/test/java/org/sonar/db/version/CreateTableBuilderTest.java index 2b11ff4eb89..3f8958d884c 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/CreateTableBuilderTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/CreateTableBuilderTest.java @@ -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)) diff --git a/sonar-db/src/test/java/org/sonar/db/version/IntegerColumnDefTest.java b/sonar-db/src/test/java/org/sonar/db/version/IntegerColumnDefTest.java index 935fb96cfd8..556dba13768 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/IntegerColumnDefTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/IntegerColumnDefTest.java @@ -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 -- 2.39.5