[#2073] The code generator's <dateAsTimestamp/> flag doesn't affect
Oracle VARRAY types
This commit is contained in:
parent
544467cd9d
commit
f2a6320cfd
@ -94,56 +94,63 @@ abstract class AbstractTypedElementDefinition<T extends Definition>
|
||||
@Override
|
||||
public DataTypeDefinition getType() {
|
||||
if (type == null) {
|
||||
Database db = container.getDatabase();
|
||||
|
||||
// [#677] Forced types for matching regular expressions
|
||||
ForcedType forcedType = db.getConfiguredForcedType(this);
|
||||
if (forcedType != null) {
|
||||
log.debug("Forcing type", this + " into " + forcedType.getName());
|
||||
DataType<?> forcedDataType = null;
|
||||
|
||||
String t = definedType.getType();
|
||||
int l = definedType.getLength();
|
||||
int p = definedType.getPrecision();
|
||||
int s = definedType.getScale();
|
||||
|
||||
try {
|
||||
forcedDataType = DefaultDataType.getDataType(db.getDialect(), forcedType.getName(), p, s);
|
||||
} catch (SQLDialectNotSupportedException ignore) {}
|
||||
|
||||
// [#677] SQLDataType matches are actual type-rewrites
|
||||
if (forcedDataType != null) {
|
||||
type = new DefaultDataTypeDefinition(db, getSchema(), forcedType.getName(), l, p, s);
|
||||
}
|
||||
|
||||
// Other forced types are UDT's, enums, etc.
|
||||
else {
|
||||
type = new DefaultDataTypeDefinition(db, getSchema(), t, l, p, s, forcedType.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// [#976] Mapping DATE as TIMESTAMP
|
||||
if (db.dateAsTimestamp()) {
|
||||
DataType<?> dataType = null;
|
||||
|
||||
try {
|
||||
dataType = DefaultDataType.getDataType(db.getDialect(), definedType.getType(), 0, 0);
|
||||
} catch (SQLDialectNotSupportedException ignore) {}
|
||||
|
||||
if (dataType != null) {
|
||||
if (dataType.getSQLType() == Types.DATE) {
|
||||
DataType<?> forcedDataType = DefaultDataType.getDataType(db.getDialect(), SQLDataType.TIMESTAMP.getTypeName(), 0, 0);
|
||||
type = new DefaultDataTypeDefinition(db, getSchema(), forcedDataType.getTypeName(), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If not yet set, use the default defined type
|
||||
if (type == null) {
|
||||
type = definedType;
|
||||
}
|
||||
type = mapDefinedType(container, this, definedType);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static DataTypeDefinition mapDefinedType(Definition container, Definition child, DataTypeDefinition definedType) {
|
||||
DataTypeDefinition result = null;
|
||||
Database db = container.getDatabase();
|
||||
|
||||
// [#677] Forced types for matching regular expressions
|
||||
ForcedType forcedType = db.getConfiguredForcedType(child);
|
||||
if (forcedType != null) {
|
||||
log.debug("Forcing type", child + " into " + forcedType.getName());
|
||||
DataType<?> forcedDataType = null;
|
||||
|
||||
String t = definedType.getType();
|
||||
int l = definedType.getLength();
|
||||
int p = definedType.getPrecision();
|
||||
int s = definedType.getScale();
|
||||
|
||||
try {
|
||||
forcedDataType = DefaultDataType.getDataType(db.getDialect(), forcedType.getName(), p, s);
|
||||
} catch (SQLDialectNotSupportedException ignore) {}
|
||||
|
||||
// [#677] SQLDataType matches are actual type-rewrites
|
||||
if (forcedDataType != null) {
|
||||
result = new DefaultDataTypeDefinition(db, child.getSchema(), forcedType.getName(), l, p, s);
|
||||
}
|
||||
|
||||
// Other forced types are UDT's, enums, etc.
|
||||
else {
|
||||
result = new DefaultDataTypeDefinition(db, child.getSchema(), t, l, p, s, forcedType.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// [#976] Mapping DATE as TIMESTAMP
|
||||
if (db.dateAsTimestamp()) {
|
||||
DataType<?> dataType = null;
|
||||
|
||||
try {
|
||||
dataType = DefaultDataType.getDataType(db.getDialect(), definedType.getType(), 0, 0);
|
||||
} catch (SQLDialectNotSupportedException ignore) {}
|
||||
|
||||
if (dataType != null) {
|
||||
if (dataType.getSQLType() == Types.DATE) {
|
||||
DataType<?> forcedDataType = DefaultDataType.getDataType(db.getDialect(), SQLDataType.TIMESTAMP.getTypeName(), 0, 0);
|
||||
result = new DefaultDataTypeDefinition(db, child.getSchema(), forcedDataType.getTypeName(), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If not yet set, use the default defined type
|
||||
if (result == null) {
|
||||
result = definedType;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,24 +38,28 @@ package org.jooq.util;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class DefaultArrayDefinition extends AbstractDefinition implements ArrayDefinition {
|
||||
|
||||
private final DataTypeDefinition type;
|
||||
private final DataTypeDefinition definedType;
|
||||
private transient DataTypeDefinition type;
|
||||
|
||||
public DefaultArrayDefinition(SchemaDefinition schema, String name, DataTypeDefinition type) {
|
||||
super(schema.getDatabase(), schema, name, "");
|
||||
|
||||
this.type = type;
|
||||
this.definedType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Definition> getDefinitionPath() {
|
||||
return Arrays.<Definition>asList(getSchema(), this);
|
||||
return Arrays.<Definition> asList(getSchema(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataTypeDefinition getElementType() {
|
||||
if (type == null) {
|
||||
type = AbstractTypedElementDefinition.mapDefinedType(this, this, definedType);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1146,7 +1146,7 @@ public class OracleTest extends jOOQAbstractTest<
|
||||
o.setD(now);
|
||||
// [#1034] TODO: Check proper use of Timestamp in array records
|
||||
DateAsTimestampT_976VarrayTypeRecord t = new DateAsTimestampT_976VarrayTypeRecord(create());
|
||||
// t.set(now, now);
|
||||
t.set(now, now);
|
||||
|
||||
record = create().newRecord(DATE_AS_TIMESTAMP_T_976);
|
||||
record.setId(2);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user