]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5471 Auto-incremented ID must start with 1 on all DB
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 12 Dec 2016 16:43:45 +0000 (17:43 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 13 Dec 2016 14:18:40 +0000 (15:18 +0100)
 - H2 was 1 in schema-h2.ddl but 0 in CreateTableBuilder
 - MSSQL was 1 in ruby but 0 in CreateTableBuilder

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

index d5d7710dd338026171f985abc58486548f802f28..eb886caf49fdadb5c341e71c346ebf22b79fa139 100644 (file)
@@ -197,13 +197,13 @@ public class CreateTableBuilder {
           // no specific clause on PostgreSQL but a specific type
           break;
         case MsSql.ID:
-          res.append(" IDENTITY (0,1)");
+          res.append(" IDENTITY (1,1)");
           break;
         case MySql.ID:
           res.append(" AUTO_INCREMENT");
           break;
         case H2.ID:
-          res.append(" AUTO_INCREMENT (0,1)");
+          res.append(" AUTO_INCREMENT (1,1)");
           break;
         default:
           throw new IllegalArgumentException("Unsupported dialect id " + dialect.getId());
index e9b765af1d1dfd30d95ec1a6e510ca101c4473b3..b83e2265e502ecd9181cfd6b48613ea574e61488 100644 (file)
@@ -275,7 +275,7 @@ public class CreateTableBuilderTest {
     assertThat(stmts).hasSize(1);
     assertThat(stmts.iterator().next())
       .isEqualTo(
-        "CREATE TABLE table_42 (id INT NOT NULL IDENTITY (0,1), CONSTRAINT pk_table_42 PRIMARY KEY (id))");
+        "CREATE TABLE table_42 (id INT NOT NULL IDENTITY (1,1), CONSTRAINT pk_table_42 PRIMARY KEY (id))");
   }
 
   @Test
@@ -286,7 +286,7 @@ public class CreateTableBuilderTest {
     assertThat(stmts).hasSize(1);
     assertThat(stmts.iterator().next())
       .isEqualTo(
-        "CREATE TABLE table_42 (id INTEGER NOT NULL AUTO_INCREMENT (0,1), CONSTRAINT pk_table_42 PRIMARY KEY (id))");
+        "CREATE TABLE table_42 (id INTEGER NOT NULL AUTO_INCREMENT (1,1), CONSTRAINT pk_table_42 PRIMARY KEY (id))");
   }
 
   @Test
@@ -526,7 +526,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) DEFAULT 'P' NOT NULL)");
+    verifyDefaultClauseOnVarcharColumn(ORACLE, "CREATE TABLE table_42 (status VARCHAR (1 CHAR) DEFAULT 'P' NOT NULL)");
   }
 
   @Test