mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-14 06:45:21 +00:00
solution v1
(cherry picked from commit 3d83c6bd0e2bcca6fc04f73ce08983266b9df636)
This commit is contained in:
1 parent
7bea0d0eb2
commit
48e875714b
2 files changed
+25
-1
No files matched your search
+22
@@ -1,6 +1,7 @@
|
||||
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
||||
|
||||
import io.ebean.annotation.ConstraintMode;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.DbConstraintNaming;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
@@ -24,6 +25,7 @@ import io.ebeaninternal.dbmigration.model.MTable;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Controls the DDL generation for a specific database platform.
|
||||
@@ -317,12 +319,32 @@ public class PlatformDdl {
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
type = extract(type);
|
||||
|
||||
if (type.contains("[]")) {
|
||||
return convertArrayType(type);
|
||||
}
|
||||
return typeConverter.convert(type);
|
||||
}
|
||||
|
||||
// if columnType is different for different platforms, use pattern
|
||||
// @Column(columnDefinition = PLATFORM1;DEFINITION1;PLATFORM2;DEFINITON2;DEFINITON-DEFAULT)
|
||||
// e.g. @Column(columnDefinition = "db2;blob(64M);sqlserver,h2;varchar(227);varchar(127)")
|
||||
private String extract(String type) {
|
||||
String[] tmp = type.split(";");
|
||||
assert tmp.length % 2 == 1;
|
||||
for (int i = 0; i < tmp.length - 2; i+=2) {
|
||||
String[] platforms = tmp[i].split(",");
|
||||
for (String plat : platforms) {
|
||||
if (platform.isPlatform(Platform.valueOf(plat.toUpperCase(Locale.ENGLISH)))) {
|
||||
return tmp[i+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return tmp[tmp.length-1]; // else
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the logical array type to a db platform specific type to support the array data.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user