mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#877 - DBMigration Generates wrong ddl for UUID type
This commit is contained in:
@@ -8,7 +8,6 @@ import static org.junit.Assert.*;
|
||||
|
||||
public class ServerConfigTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testLoadFromEbeanProperties() {
|
||||
|
||||
@@ -41,7 +40,7 @@ public class ServerConfigTest {
|
||||
assertTrue(serverConfig.isH2ProductionMode());
|
||||
assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatch());
|
||||
assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatchOnCascade());
|
||||
assertEquals(ServerConfig.DbUuid.BINARY, serverConfig.getDbUuid());
|
||||
assertEquals(ServerConfig.DbUuid.BINARY, serverConfig.getDbTypeConfig().getDbUuid());
|
||||
assertEquals(42, serverConfig.getJdbcFetchSizeFindEach());
|
||||
assertEquals(43, serverConfig.getJdbcFetchSizeFindList());
|
||||
assertEquals(4, serverConfig.getBackgroundExecutorSchedulePoolSize());
|
||||
@@ -60,4 +59,4 @@ public class ServerConfigTest {
|
||||
assertEquals(PersistBatch.ALL, serverConfig.getPersistBatch());
|
||||
assertEquals(PersistBatch.ALL, serverConfig.getPersistBatchOnCascade());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.avaje.ebean.config.dbplatform;
|
||||
|
||||
import com.avaje.ebean.config.DbTypeConfig;
|
||||
import com.avaje.ebean.config.Platform;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DatabasePlatformTest {
|
||||
|
||||
@@ -19,19 +19,19 @@ public class DatabasePlatformTest {
|
||||
@Test
|
||||
public void configure_customType() throws Exception {
|
||||
|
||||
ServerConfig serverConfig = new ServerConfig();
|
||||
serverConfig.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES);
|
||||
serverConfig.addCustomMapping(DbType.DECIMAL, "decimal(24,4)");
|
||||
DbTypeConfig config = new DbTypeConfig();
|
||||
config.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES);
|
||||
config.addCustomMapping(DbType.DECIMAL, "decimal(24,4)");
|
||||
|
||||
// PG renders custom decimal and varchar
|
||||
PostgresPlatform pgPlatform = new PostgresPlatform();
|
||||
pgPlatform.configure(serverConfig);
|
||||
pgPlatform.configure(config);
|
||||
assertEquals(defaultDecimalDefn(pgPlatform), "decimal(24,4)");
|
||||
assertEquals(defaultDefn(DbType.VARCHAR, pgPlatform), "text");
|
||||
|
||||
// H2 only renders custom decimal
|
||||
H2Platform h2Platform = new H2Platform();
|
||||
h2Platform.configure(serverConfig);
|
||||
h2Platform.configure(config);
|
||||
assertEquals(defaultDecimalDefn(h2Platform), "decimal(24,4)");
|
||||
assertEquals(defaultDefn(DbType.VARCHAR, h2Platform), "varchar(255)");
|
||||
}
|
||||
@@ -43,4 +43,4 @@ public class DatabasePlatformTest {
|
||||
private String defaultDefn(DbType type, DatabasePlatform dbPlatform) {
|
||||
return dbPlatform.getDbTypeMap().get(type).renderType(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.avaje.ebean.config.dbplatform;
|
||||
|
||||
import com.avaje.ebean.config.DbTypeConfig;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl;
|
||||
import org.junit.Test;
|
||||
@@ -25,7 +26,7 @@ public class MySqlPlatformTest {
|
||||
public void uuid_default() {
|
||||
|
||||
MySqlPlatform platform = new MySqlPlatform();
|
||||
platform.configure(new ServerConfig());
|
||||
platform.configure(new DbTypeConfig());
|
||||
|
||||
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
|
||||
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar(40)");
|
||||
@@ -36,12 +37,12 @@ public class MySqlPlatformTest {
|
||||
public void uuid_as_binary() {
|
||||
|
||||
MySqlPlatform platform = new MySqlPlatform();
|
||||
ServerConfig serverConfig = new ServerConfig();
|
||||
serverConfig.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY);
|
||||
platform.configure(serverConfig);
|
||||
DbTypeConfig config = new DbTypeConfig();
|
||||
config.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY);
|
||||
platform.configure(config);
|
||||
|
||||
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
|
||||
assertThat(dbType.renderType(0, 0)).isEqualTo("binary(16)");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.avaje.ebean.config.dbplatform;
|
||||
|
||||
import com.avaje.ebean.config.DbTypeConfig;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl;
|
||||
import org.junit.Test;
|
||||
@@ -34,7 +35,7 @@ public class OraclePlatformTest {
|
||||
public void uuid_default() {
|
||||
|
||||
OraclePlatform platform = new OraclePlatform();
|
||||
platform.configure(new ServerConfig());
|
||||
platform.configure(new DbTypeConfig());
|
||||
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
|
||||
|
||||
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar2(40)");
|
||||
@@ -45,12 +46,12 @@ public class OraclePlatformTest {
|
||||
public void uuid_as_binary() {
|
||||
|
||||
OraclePlatform platform = new OraclePlatform();
|
||||
ServerConfig serverConfig = new ServerConfig();
|
||||
serverConfig.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY);
|
||||
DbTypeConfig config = new DbTypeConfig();
|
||||
config.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY);
|
||||
|
||||
platform.configure(serverConfig);
|
||||
platform.configure(config);
|
||||
|
||||
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
|
||||
assertThat(dbType.renderType(0, 0)).isEqualTo("raw(16)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.avaje.ebean.config.dbplatform;
|
||||
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.DbTypeConfig;
|
||||
import com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PostgresPlatformTest {
|
||||
public void testUuidType() {
|
||||
|
||||
PostgresPlatform platform = new PostgresPlatform();
|
||||
platform.configure(new ServerConfig());
|
||||
platform.configure(new DbTypeConfig());
|
||||
|
||||
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
|
||||
String columnDefn = dbType.renderType(0, 0);
|
||||
@@ -44,4 +44,4 @@ public class PostgresPlatformTest {
|
||||
assertThat(columnDefn).isEqualTo("uuid");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user