001package io.ebean.config.dbplatform.clickhouse; 002 003import io.ebean.annotation.Platform; 004import io.ebean.config.dbplatform.DatabasePlatform; 005import io.ebean.config.dbplatform.DbPlatformType; 006import io.ebean.config.dbplatform.DbType; 007import io.ebean.config.dbplatform.IdType; 008 009import java.sql.Types; 010 011public class ClickHousePlatform extends DatabasePlatform { 012 013 public ClickHousePlatform() { 014 super(); 015 this.platform = Platform.CLICKHOUSE; 016 //this.dbEncrypt = 017 //this.historySupport = 018 //this.exceptionTranslator = 019 this.nativeUuidType = true; 020 this.dbDefaultValue.setNow("now()"); 021 022 this.dbIdentity.setIdType(IdType.IDENTITY); 023 this.dbIdentity.setSupportsGetGeneratedKeys(false); 024 this.dbIdentity.setSupportsSequence(false); 025 this.dbIdentity.setSupportsIdentity(true); 026 027 this.booleanDbType = Types.INTEGER; 028 dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("UInt8")); 029 030 // using unsigned as default types ... 031 dbTypeMap.put(DbType.TINYINT, new DbPlatformType("UInt8", false)); 032 dbTypeMap.put(DbType.SMALLINT, new DbPlatformType("UInt16", false)); 033 dbTypeMap.put(DbType.INTEGER, new DbPlatformType("UInt32", false)); 034 dbTypeMap.put(DbType.BIGINT, new DbPlatformType("UInt64", false)); 035 dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("Decimal", 16, 3)); 036 dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("Float64", false)); 037 038 dbTypeMap.put(DbType.DATE, new DbPlatformType("Date", false)); 039 dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType("DateTime", false)); 040 041 dbTypeMap.put(DbType.VARCHAR, new DbPlatformType("String", false)); 042 dbTypeMap.put(DbType.LONGVARCHAR, new DbPlatformType("String", false)); 043 dbTypeMap.put(DbType.CLOB, new DbPlatformType("String", false)); 044 dbTypeMap.put(DbType.JSONVARCHAR, new DbPlatformType("String", false)); 045 046 dbTypeMap.put(DbType.UUID, new DbPlatformType("UUID", false)); 047 dbTypeMap.put(DbType.INET, new DbPlatformType("String", false)); 048 dbTypeMap.put(DbType.CIDR, new DbPlatformType("String", false)); 049 } 050 051 @Override 052 public boolean isNativeArrayType() { 053 return true; 054 } 055 056}