mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#769 - DB Migration DDL generation for UUID type when generating multiple platforms
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.avaje.ebean.config.dbplatform;
|
||||
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -20,4 +21,27 @@ public class MySqlPlatformTest {
|
||||
assertThat(ddl.convert("bit", false)).isEqualTo("tinyint(1) default 0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uuid_default() {
|
||||
|
||||
MySqlPlatform platform = new MySqlPlatform();
|
||||
platform.configure(new ServerConfig());
|
||||
|
||||
DbType dbType = platform.getDbTypeMap().get(DbType.UUID);
|
||||
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar(40)");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void uuid_as_binary() {
|
||||
|
||||
MySqlPlatform platform = new MySqlPlatform();
|
||||
ServerConfig serverConfig = new ServerConfig();
|
||||
serverConfig.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY);
|
||||
platform.configure(serverConfig);
|
||||
|
||||
DbType dbType = platform.getDbTypeMap().get(DbType.UUID);
|
||||
assertThat(dbType.renderType(0, 0)).isEqualTo("binary(16)");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.avaje.ebean.config.dbplatform;
|
||||
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -29,4 +30,27 @@ public class OraclePlatformTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uuid_default() {
|
||||
|
||||
OraclePlatform platform = new OraclePlatform();
|
||||
platform.configure(new ServerConfig());
|
||||
DbType dbType = platform.getDbTypeMap().get(DbType.UUID);
|
||||
|
||||
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar2(40)");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void uuid_as_binary() {
|
||||
|
||||
OraclePlatform platform = new OraclePlatform();
|
||||
ServerConfig serverConfig = new ServerConfig();
|
||||
serverConfig.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY);
|
||||
|
||||
platform.configure(serverConfig);
|
||||
|
||||
DbType dbType = platform.getDbTypeMap().get(DbType.UUID);
|
||||
assertThat(dbType.renderType(0, 0)).isEqualTo("binary(16)");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.avaje.ebean.config.dbplatform;
|
||||
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -7,11 +8,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class PostgresPlatformTest {
|
||||
|
||||
PostgresPlatform platform = new PostgresPlatform();
|
||||
|
||||
|
||||
@Test
|
||||
public void testTypeConversion() {
|
||||
|
||||
PostgresPlatform platform = new PostgresPlatform();
|
||||
PlatformDdl ddl = platform.getPlatformDdl();
|
||||
|
||||
assertThat(ddl.convert("clob", false)).isEqualTo("text");
|
||||
@@ -30,4 +32,16 @@ public class PostgresPlatformTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUuidType() {
|
||||
|
||||
PostgresPlatform platform = new PostgresPlatform();
|
||||
platform.configure(new ServerConfig());
|
||||
|
||||
DbType dbType = platform.getDbTypeMap().get(DbType.UUID);
|
||||
String columnDefn = dbType.renderType(0, 0);
|
||||
|
||||
assertThat(columnDefn).isEqualTo("uuid");
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class ModelBuildBeanVisitorTest extends BaseTestCase {
|
||||
DbConstraintNaming constraintNaming = defaultServer.getServerConfig().getConstraintNaming();
|
||||
|
||||
DefaultConstraintMaxLength maxLength = new DefaultConstraintMaxLength(60);
|
||||
ModelBuildContext ctx = new ModelBuildContext(model, constraintNaming, maxLength);
|
||||
ModelBuildContext ctx = new ModelBuildContext(model, constraintNaming, maxLength, true);
|
||||
|
||||
ModelBuildBeanVisitor addTable = new ModelBuildBeanVisitor(ctx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user