mirror of
https://github.com/getrebuild/rebuild.git
synced 2024-11-10 08:55:31 +08:00
hotfix: field type cast
This commit is contained in:
parent
1b2eb3b421
commit
a6acdd97ac
2 changed files with 19 additions and 2 deletions
|
@ -79,7 +79,7 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
|
||||||
/**
|
/**
|
||||||
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
|
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
|
||||||
*/
|
*/
|
||||||
public static final int BUILD = 3070308;
|
public static final int BUILD = 3070309;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Driver for DB
|
// Driver for DB
|
||||||
|
|
|
@ -47,6 +47,10 @@ import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.rebuild.core.metadata.impl.EasyFieldConfigProps.DATETIME_CALCFORMULA;
|
||||||
|
import static com.rebuild.core.metadata.impl.EasyFieldConfigProps.DATETIME_FORMAT;
|
||||||
|
import static com.rebuild.core.metadata.impl.EasyFieldConfigProps.DATE_CALCFORMULA;
|
||||||
|
import static com.rebuild.core.metadata.impl.EasyFieldConfigProps.DATE_FORMAT;
|
||||||
import static com.rebuild.core.metadata.impl.EasyFieldConfigProps.NUMBER_CALCFORMULA;
|
import static com.rebuild.core.metadata.impl.EasyFieldConfigProps.NUMBER_CALCFORMULA;
|
||||||
import static com.rebuild.core.metadata.impl.EasyFieldConfigProps.NUMBER_NOTNEGATIVE;
|
import static com.rebuild.core.metadata.impl.EasyFieldConfigProps.NUMBER_NOTNEGATIVE;
|
||||||
|
|
||||||
|
@ -450,6 +454,8 @@ public class Field2Schema extends SetUser {
|
||||||
// 保留部分扩展配置,其余移除避免冲突
|
// 保留部分扩展配置,其余移除避免冲突
|
||||||
JSONObject extraAttrs = fieldEasy.getExtraAttrs();
|
JSONObject extraAttrs = fieldEasy.getExtraAttrs();
|
||||||
if (!extraAttrs.isEmpty()) {
|
if (!extraAttrs.isEmpty()) {
|
||||||
|
extraAttrs.remove(DATE_FORMAT);
|
||||||
|
extraAttrs.remove(DATETIME_FORMAT);
|
||||||
Object notNegative = extraAttrs.remove(NUMBER_NOTNEGATIVE);
|
Object notNegative = extraAttrs.remove(NUMBER_NOTNEGATIVE);
|
||||||
Object calcFormula = extraAttrs.remove(NUMBER_CALCFORMULA);
|
Object calcFormula = extraAttrs.remove(NUMBER_CALCFORMULA);
|
||||||
|
|
||||||
|
@ -468,6 +474,17 @@ public class Field2Schema extends SetUser {
|
||||||
MetadataHelper.getMetadataFactory().refresh();
|
MetadataHelper.getMetadataFactory().refresh();
|
||||||
field = MetadataHelper.getField(field.getOwnEntity().getName(), field.getName());
|
field = MetadataHelper.getField(field.getOwnEntity().getName(), field.getName());
|
||||||
|
|
||||||
|
// 去除默认值
|
||||||
|
try {
|
||||||
|
java.lang.reflect.Field defaultValueOfField = field.getClass().getDeclaredField("defaultValue");
|
||||||
|
defaultValueOfField.setAccessible(true);
|
||||||
|
defaultValueOfField.set(field, null);
|
||||||
|
java.lang.reflect.Field nullableOfField = field.getClass().getDeclaredField("nullable");
|
||||||
|
nullableOfField.setAccessible(true);
|
||||||
|
nullableOfField.set(field, true);
|
||||||
|
} catch (ReflectiveOperationException ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
String alterTypeSql = null;
|
String alterTypeSql = null;
|
||||||
try {
|
try {
|
||||||
Dialect dialect = Application.getPersistManagerFactory().getDialect();
|
Dialect dialect = Application.getPersistManagerFactory().getDialect();
|
||||||
|
@ -487,7 +504,7 @@ public class Field2Schema extends SetUser {
|
||||||
fieldMeta.setString("displayType", EasyMetaFactory.getDisplayType(field).name());
|
fieldMeta.setString("displayType", EasyMetaFactory.getDisplayType(field).name());
|
||||||
Application.getCommonsService().update(fieldMeta, false);
|
Application.getCommonsService().update(fieldMeta, false);
|
||||||
|
|
||||||
log.error("DDL ERROR : \n" + alterTypeSql, ex);
|
log.error("DDL ERROR : \n{}", alterTypeSql, ex);
|
||||||
|
|
||||||
Throwable cause = ThrowableUtils.getRootCause(ex);
|
Throwable cause = ThrowableUtils.getRootCause(ex);
|
||||||
String causeMsg = cause.getLocalizedMessage();
|
String causeMsg = cause.getLocalizedMessage();
|
||||||
|
|
Loading…
Reference in a new issue