From 499048f6c3151724a1271b30b9fe8e6923cdda41 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Wed, 14 Sep 2016 15:58:11 +0200 Subject: [PATCH] SONAR-8025 rename columns DATA as they are reserved words --- .../src/main/java/org/sonar/db/ce/CeScannerContextDao.java | 4 ++-- sonar-db/src/main/java/org/sonar/db/ce/CeTaskInputDao.java | 4 ++-- .../java/org/sonar/db/version/v61/CreateTableCeTaskInput.java | 2 +- .../org/sonar/db/version/v61/CreateTableScannerContext.java | 2 +- .../src/main/resources/org/sonar/db/version/schema-h2.ddl | 4 ++-- .../org/sonar/db/version/v61/CreateTableCeTaskInputTest.java | 2 +- .../sonar/db/version/v61/CreateTableScannerContextTest.java | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeScannerContextDao.java b/sonar-db/src/main/java/org/sonar/db/ce/CeScannerContextDao.java index fd7dbdeec9f..6b62a1718d2 100644 --- a/sonar-db/src/main/java/org/sonar/db/ce/CeScannerContextDao.java +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeScannerContextDao.java @@ -55,7 +55,7 @@ public class CeScannerContextDao implements Dao { long now = system.now(); Connection connection = dbSession.getConnection(); try (PreparedStatement stmt = connection.prepareStatement( - "INSERT INTO ce_scanner_context (task_uuid, created_at, updated_at, data) VALUES (?, ?, ?, ?)"); + "INSERT INTO ce_scanner_context (task_uuid, created_at, updated_at, context_data) VALUES (?, ?, ?, ?)"); InputStream inputStream = new LogsIteratorInputStream(scannerContextLines, UTF_8)) { stmt.setString(1, taskUuid); stmt.setLong(2, now); @@ -73,7 +73,7 @@ public class CeScannerContextDao implements Dao { * whichever the platform SQ is running on ({@see LogsIteratorInputStream}). */ public Optional selectScannerContext(DbSession dbSession, String taskUuid) { - try (PreparedStatement stmt = dbSession.getConnection().prepareStatement("select data from ce_scanner_context where task_uuid=?")) { + try (PreparedStatement stmt = dbSession.getConnection().prepareStatement("select context_data from ce_scanner_context where task_uuid=?")) { stmt.setString(1, taskUuid); try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeTaskInputDao.java b/sonar-db/src/main/java/org/sonar/db/ce/CeTaskInputDao.java index ed418eed5f7..3654531f791 100644 --- a/sonar-db/src/main/java/org/sonar/db/ce/CeTaskInputDao.java +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeTaskInputDao.java @@ -45,7 +45,7 @@ public class CeTaskInputDao implements Dao { long now = system.now(); Connection connection = dbSession.getConnection(); try (PreparedStatement stmt = connection.prepareStatement( - "INSERT INTO ce_task_input (task_uuid, created_at, updated_at, data) VALUES (?, ?, ?, ?)")) { + "INSERT INTO ce_task_input (task_uuid, created_at, updated_at, input_data) VALUES (?, ?, ?, ?)")) { stmt.setString(1, taskUuid); stmt.setLong(2, now); stmt.setLong(3, now); @@ -62,7 +62,7 @@ public class CeTaskInputDao implements Dao { ResultSet rs = null; DataStream result = null; try { - stmt = dbSession.getConnection().prepareStatement("SELECT data FROM ce_task_input WHERE task_uuid=? AND data IS NOT NULL"); + stmt = dbSession.getConnection().prepareStatement("SELECT input_data FROM ce_task_input WHERE task_uuid=? AND input_data IS NOT NULL"); stmt.setString(1, taskUuid); rs = stmt.executeQuery(); if (rs.next()) { diff --git a/sonar-db/src/main/java/org/sonar/db/version/v61/CreateTableCeTaskInput.java b/sonar-db/src/main/java/org/sonar/db/version/v61/CreateTableCeTaskInput.java index fc4d3ec1337..1bcc1e13bc5 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v61/CreateTableCeTaskInput.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v61/CreateTableCeTaskInput.java @@ -39,7 +39,7 @@ public class CreateTableCeTaskInput extends DdlChange { context.execute( new CreateTableBuilder(getDialect(), "ce_task_input") .addPkColumn(newVarcharColumnDefBuilder().setColumnName("task_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) - .addColumn(newBlobColumnDefBuilder().setColumnName("data").setIsNullable(true).build()) + .addColumn(newBlobColumnDefBuilder().setColumnName("input_data").setIsNullable(true).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) .build()); diff --git a/sonar-db/src/main/java/org/sonar/db/version/v61/CreateTableScannerContext.java b/sonar-db/src/main/java/org/sonar/db/version/v61/CreateTableScannerContext.java index 6d20e820c47..57edc4a574c 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v61/CreateTableScannerContext.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v61/CreateTableScannerContext.java @@ -39,7 +39,7 @@ public class CreateTableScannerContext extends DdlChange { context.execute( new CreateTableBuilder(getDialect(), "ce_scanner_context") .addPkColumn(newVarcharColumnDefBuilder().setColumnName("task_uuid").setLimit(UUID_SIZE).setIsNullable(false).build()) - .addColumn(newBlobColumnDefBuilder().setColumnName("data").setIsNullable(false).build()) + .addColumn(newBlobColumnDefBuilder().setColumnName("context_data").setIsNullable(false).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) .build()); diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl index 6b5b37e0aeb..293743b8b8a 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -552,14 +552,14 @@ CREATE TABLE "CE_ACTIVITY" ( CREATE TABLE "CE_TASK_INPUT" ( "TASK_UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "DATA" BLOB(167772150), + "INPUT_DATA" BLOB(167772150), "CREATED_AT" BIGINT NOT NULL, "UPDATED_AT" BIGINT NOT NULL ); CREATE TABLE "CE_SCANNER_CONTEXT" ( "TASK_UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "DATA" BLOB(167772150) NOT NULL, + "CONTEXT_DATA" BLOB(167772150) NOT NULL, "CREATED_AT" BIGINT NOT NULL, "UPDATED_AT" BIGINT NOT NULL ); diff --git a/sonar-db/src/test/java/org/sonar/db/version/v61/CreateTableCeTaskInputTest.java b/sonar-db/src/test/java/org/sonar/db/version/v61/CreateTableCeTaskInputTest.java index ff4d366d5c1..eb6d1dfd1a5 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/v61/CreateTableCeTaskInputTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/v61/CreateTableCeTaskInputTest.java @@ -46,7 +46,7 @@ public class CreateTableCeTaskInputTest { assertThat(dbTester.countRowsOfTable(TABLE_CE_TASK_INPUT)).isEqualTo(0); dbTester.assertColumnDefinition(TABLE_CE_TASK_INPUT, "task_uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_CE_TASK_INPUT, "data", Types.BLOB, null, true); + dbTester.assertColumnDefinition(TABLE_CE_TASK_INPUT, "input_data", Types.BLOB, null, true); dbTester.assertColumnDefinition(TABLE_CE_TASK_INPUT, "created_at", Types.BIGINT, null, false); dbTester.assertColumnDefinition(TABLE_CE_TASK_INPUT, "updated_at", Types.BIGINT, null, false); dbTester.assertPrimaryKey(TABLE_CE_TASK_INPUT, "pk_" + TABLE_CE_TASK_INPUT, "task_uuid"); diff --git a/sonar-db/src/test/java/org/sonar/db/version/v61/CreateTableScannerContextTest.java b/sonar-db/src/test/java/org/sonar/db/version/v61/CreateTableScannerContextTest.java index 97780fd4dfb..0847efdae5d 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/v61/CreateTableScannerContextTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/v61/CreateTableScannerContextTest.java @@ -46,7 +46,7 @@ public class CreateTableScannerContextTest { assertThat(dbTester.countRowsOfTable(TABLE_CE_SCANNER_CONTEXT)).isEqualTo(0); dbTester.assertColumnDefinition(TABLE_CE_SCANNER_CONTEXT, "task_uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_CE_SCANNER_CONTEXT, "data", Types.BLOB, null, false); + dbTester.assertColumnDefinition(TABLE_CE_SCANNER_CONTEXT, "context_data", Types.BLOB, null, false); dbTester.assertColumnDefinition(TABLE_CE_SCANNER_CONTEXT, "created_at", Types.BIGINT, null, false); dbTester.assertColumnDefinition(TABLE_CE_SCANNER_CONTEXT, "updated_at", Types.BIGINT, null, false); dbTester.assertPrimaryKey(TABLE_CE_SCANNER_CONTEXT, "pk_" + TABLE_CE_SCANNER_CONTEXT, "task_uuid"); -- 2.39.5