mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1011 - Create valid migration scripts for non-Postgres databases and @DbArray columns.
Merge branch 'test/dbarray-create-migration' of https://github.com/FOCONIS/ebean into FOCONIS-test/dbarray-create-migration
commit 3a8f32b173
Author: Michael Benz <michael.benz@foconis.de>
Date: Wed Apr 19 18:16:51 2017 +0200
adding dbmigration ddlgeneration test for Ebean @DbArray extension.
This commit is contained in:
@@ -245,13 +245,15 @@ public class DeployUtil {
|
||||
prop.setDbType(dbType);
|
||||
prop.setScalarType(scalarType);
|
||||
if (scalarType instanceof ScalarTypeArray) {
|
||||
prop.setDbColumnDefn(((ScalarTypeArray) scalarType).getDbColumnDefn());
|
||||
}
|
||||
if (dbType == Types.VARCHAR) {
|
||||
// determine the db column size
|
||||
int dbLength = dbArray.length();
|
||||
int columnLength = (dbLength > 0) ? dbLength : DEFAULT_ARRAY_VARCHAR_LENGTH;
|
||||
prop.setDbLength(columnLength);
|
||||
String columnDefn = ((ScalarTypeArray) scalarType).getDbColumnDefn();
|
||||
if (dbArray.length() > 0) {
|
||||
// fallback varchar column length when ARRAY not support by DB
|
||||
columnDefn += "(" + dbArray.length() + ")";
|
||||
}
|
||||
prop.setDbLength(dbArray.length());
|
||||
prop.setDbColumnDefn(columnDefn);
|
||||
} else {
|
||||
throw new RuntimeException("Not mapped to ScalarTypeArray? " + scalarType.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user