diff --git a/ebean-api/src/main/java/io/ebean/config/dbplatform/clickhouse/ClickHousePlatform.java b/ebean-api/src/main/java/io/ebean/config/dbplatform/clickhouse/ClickHousePlatform.java index f1e8eca21..bb1b141e6 100644 --- a/ebean-api/src/main/java/io/ebean/config/dbplatform/clickhouse/ClickHousePlatform.java +++ b/ebean-api/src/main/java/io/ebean/config/dbplatform/clickhouse/ClickHousePlatform.java @@ -18,6 +18,8 @@ public class ClickHousePlatform extends DatabasePlatform { //this.exceptionTranslator = this.nativeUuidType = true; this.dbDefaultValue.setNow("now()"); + this.dbDefaultValue.setFalse("0"); + this.dbDefaultValue.setTrue("1"); this.dbIdentity.setIdType(IdType.IDENTITY); this.dbIdentity.setSupportsGetGeneratedKeys(false); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DScriptRunner.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DScriptRunner.java index fdb24bd0d..06916912c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DScriptRunner.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DScriptRunner.java @@ -106,7 +106,9 @@ final class DScriptRunner implements ScriptRunner { try (Connection connection = obtainConnection()) { DdlRunner runner = new DdlRunner(useAutoCommit, scriptName, platformName); runner.runAll(content, connection); - connection.commit(); + if (!connection.getAutoCommit()) { + connection.commit(); + } runner.runNonTransactional(connection); } diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql index 1d41eabbe..b4b1ecfff 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql @@ -53,7 +53,7 @@ create table migtest_e_basic ( description String, description_file blob, some_date DateTime, - old_boolean UInt8 default false, + old_boolean UInt8 default 0, old_boolean2 UInt8, eref_id UInt32, indextest1 String, diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql index 56fd182db..eef3c8083 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql @@ -48,8 +48,8 @@ alter table migtest_e_basic alter column status2 drop default; alter table migtest_e_basic alter column status2 set null; alter table migtest_e_basic alter column user_id set null; alter table migtest_e_basic add column new_string_field String default 'foo''bar'; -alter table migtest_e_basic add column new_boolean_field UInt8 default true; -alter table migtest_e_basic add column new_boolean_field2 UInt8 default true; +alter table migtest_e_basic add column new_boolean_field UInt8 default 1; +alter table migtest_e_basic add column new_boolean_field2 UInt8 default 1; alter table migtest_e_basic add column progress UInt32 default 0; alter table migtest_e_basic add column new_integer UInt32 default 42; alter table migtest_e_history alter column test_string UInt64; @@ -59,11 +59,11 @@ alter table migtest_e_history2 add column test_string2 String; alter table migtest_e_history2 add column test_string3 String default 'unknown'; alter table migtest_e_history2 add column new_column String; alter table migtest_e_history4 alter column test_number UInt64; -alter table migtest_e_history5 add column test_boolean UInt8 default false; +alter table migtest_e_history5 add column test_boolean UInt8 default 0; alter table migtest_e_history6 alter column test_number1 set default 42; alter table migtest_e_history6 alter column test_number1 set not null; alter table migtest_e_history6 alter column test_number2 set null; -alter table migtest_e_softdelete add column deleted UInt8 default false; +alter table migtest_e_softdelete add column deleted UInt8 default 0; alter table migtest_oto_child add column master_id UInt64; -- apply post alter alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.3.sql index 155817baa..523858c49 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.3.sql @@ -30,7 +30,7 @@ alter table migtest_e_basic alter column status2 set not null; alter table migtest_e_basic alter column user_id set default 23; alter table migtest_e_basic alter column user_id set not null; alter table migtest_e_basic add column description_file blob; -alter table migtest_e_basic add column old_boolean UInt8 default false; +alter table migtest_e_basic add column old_boolean UInt8 default 0; alter table migtest_e_basic add column old_boolean2 UInt8; alter table migtest_e_basic add column eref_id UInt32; alter table migtest_e_history2 alter column test_string drop default; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations index 86feb1c0a..836030b83 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations @@ -1,6 +1,6 @@ --697238714, 1.0__initial.sql --1523257380, 1.1.sql +1588846231, 1.0__initial.sql +-1102375855, 1.1.sql 1279151426, 1.2__dropsFor_1.1.sql -14388492, 1.3.sql +581928632, 1.3.sql 80209848, 1.4__dropsFor_1.3.sql