Skip to content
Permalink
Browse files

0004065: Allow zero date on MySQL or convert to null otherwise (3.10)

  • Loading branch information...
erilong committed Aug 8, 2019
1 parent e74334b commit ffa2568bdd3b752c49e4de9026d6c6c37bc61868
@@ -84,6 +84,7 @@

public static final String REQUIRED_FIELD_NULL_SUBSTITUTE = " ";

public static final String ZERO_DATE_STRING = "0000-00-00 00:00:00";
/*
* The default name for models read from the database, if no name as given.
*/
@@ -926,6 +927,9 @@ public boolean canColumnBeUsedInWhereClause(Column column) {
try {
return Timestamp.valueOf(value);
} catch (IllegalArgumentException ex) {
if (!getDatabaseInfo().isZeroDateAllowed() && value != null && value.startsWith(ZERO_DATE_STRING)) {
return null;
}
try {
return new Timestamp(FormatUtils.parseDate(value, FormatUtils.TIMESTAMP_PATTERNS).getTime());
} catch (Exception e) {
@@ -275,6 +275,8 @@

private boolean notNullColumnsSupported = true;

private boolean zeroDateAllowed;

/**
* Creates a new platform info object.
*/
@@ -1357,5 +1359,12 @@ public void setNotNullColumnsSupported(boolean notNullColumnsSupported) {
this.notNullColumnsSupported = notNullColumnsSupported;
}


public boolean isZeroDateAllowed() {
return zeroDateAllowed;
}

public void setZeroDateAllowed(boolean zeroDateAllowed) {
this.zeroDateAllowed = zeroDateAllowed;
}

}
@@ -65,6 +65,7 @@ public MySqlDdlBuilder() {
// Double quotes are only allowed for delimiting identifiers if the
// server SQL mode includes ANSI_QUOTES
databaseInfo.setDelimiterToken("`");
databaseInfo.setZeroDateAllowed(true);

databaseInfo.addNativeTypeMapping(Types.ARRAY, "LONGBLOB", Types.LONGVARBINARY);
databaseInfo.addNativeTypeMapping(Types.BIT, "BIT");

0 comments on commit ffa2568

Please sign in to comment.
You can’t perform that action at this time.