mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1653 - ENH: Add support for ClickHouse database
With array type conversion etc
This commit is contained in:
+18
@@ -2,6 +2,7 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
||||
|
||||
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.dbplatform.clickhouse.ClickHousePlatform;
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
||||
import io.ebean.config.dbplatform.oracle.OraclePlatform;
|
||||
@@ -62,6 +63,23 @@ public class BaseTableDdlTest {
|
||||
assertThat(ddl).contains("alter table mytable add column col_name varchar2(20)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddColumn_withTypeConversion_clickHouseVarchar() throws IOException {
|
||||
|
||||
ClickHouseTableDdl ddlGen = new ClickHouseTableDdl(serverConfig, PlatformDdlBuilder.create(new ClickHousePlatform()));
|
||||
|
||||
DdlWrite write = new DdlWrite();
|
||||
|
||||
Column column = new Column();
|
||||
column.setName("col_name");
|
||||
column.setType("varchar(20)");
|
||||
|
||||
ddlGen.alterTableAddColumn(write.apply(), "mytable", column, false, false);
|
||||
|
||||
String ddl = write.apply().getBuffer();
|
||||
assertThat(ddl).contains("alter table mytable add column col_name String");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAlterColumnComment() throws IOException {
|
||||
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ClickHouseDbArrayTest {
|
||||
|
||||
@Test
|
||||
public void logicalToNative() {
|
||||
|
||||
assertThat(ClickHouseDbArray.logicalToNative("uuid[]")).isEqualTo("Array(UUID)");
|
||||
assertThat(ClickHouseDbArray.logicalToNative("varchar[]")).isEqualTo("Array(String)");
|
||||
assertThat(ClickHouseDbArray.logicalToNative("integer[]")).isEqualTo("Array(UInt32)");
|
||||
assertThat(ClickHouseDbArray.logicalToNative("bigint[]")).isEqualTo("Array(UInt64)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void logicalToNative_withFallbackDefined() {
|
||||
|
||||
assertThat(ClickHouseDbArray.logicalToNative("uuid[]:(1000)")).isEqualTo("Array(UUID)");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user