OPENJPA-2865 add compat check for WITH_TIMEZONE cols

This commit is contained in:
Mark Struberg 2021-05-02 22:23:50 +02:00
parent c780084ccd
commit 8e18fdbbbc
3 changed files with 22 additions and 4 deletions

View File

@ -770,8 +770,8 @@ public abstract class MappingInfo implements Serializable {
if (col == null) {
col = table.addColumn(colName);
col.setType(type);
} else if ((compat || !ttype) && !col.isCompatible(type, typeName,
size, decimals)) {
} else if ((compat || !ttype) &&
!col.isCompatible(type, typeName, size, decimals)) {
// if existing column isn't compatible with desired type, die if
// can't adapt, else warn and change the existing column type
Message msg = _loc.get(prefix + "-bad-col", context,

View File

@ -762,10 +762,29 @@ public class Column extends ReferenceCounter {
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
case Types.TIMESTAMP_WITH_TIMEZONE:
return true;
default:
return false;
}
case Types.TIMESTAMP_WITH_TIMEZONE:
switch (type) {
case Types.DATE:
case Types.TIMESTAMP:
return true;
default:
return false;
}
case Types.TIME_WITH_TIMEZONE:
switch (type) {
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
return true;
default:
return false;
}
case Types.SQLXML: // All XML Types
case 2007: // Oracle-defined opaque type code for XMLType treated the same way
switch (type) {

View File

@ -240,8 +240,7 @@ public class DynamicSchemaFactory
}
@Override
public boolean isCompatible(int type, String typeName, int size,
int decimals) {
public boolean isCompatible(int type, String typeName, int size, int decimals) {
if (getType() != Types.OTHER)
return super.isCompatible(type, typeName, size, decimals);