[jOOQ/jOOQ#10797] Applying a forcedType prevents identity(true) from being generated

This commit is contained in:
Lukas Eder 2020-10-26 11:35:19 +01:00
parent 69112c4434
commit 0cfdaf5082
2 changed files with 11 additions and 6 deletions

View File

@ -197,7 +197,6 @@ public abstract class AbstractTypedElementDefinition<T extends Definition>
return result;
}
@SuppressWarnings("deprecation")
public static final DataTypeDefinition mapDefinedType(Definition container, Definition child, DataTypeDefinition definedType, JavaTypeResolver resolver) {
DataTypeDefinition result = definedType;
Database db = container.getDatabase();
@ -229,8 +228,8 @@ public abstract class AbstractTypedElementDefinition<T extends Definition>
child.getSchema(),
forcedDataType.getTypeName(),
0, 0, 0,
result.isNullable(), result.getDefaultValue(), (Name) null, null,
binding
result.isNullable(), result.getDefaultValue(), result.isIdentity(), (Name) null, null,
binding, null
);
}
}
@ -276,6 +275,7 @@ public abstract class AbstractTypedElementDefinition<T extends Definition>
boolean n = result.isNullable();
String d = result.getDefaultValue();
boolean i = result.isIdentity();
int l = 0;
int p = 0;
@ -304,7 +304,7 @@ public abstract class AbstractTypedElementDefinition<T extends Definition>
if (customType != null)
log.warn("Custom type conflict", child + " has custom type " + customType + " forced by " + forcedType + " but a data type rewrite applies");
result = new DefaultDataTypeDefinition(db, child.getSchema(), uType, l, p, s, n, d, (Name) null, converter, binding);
result = new DefaultDataTypeDefinition(db, child.getSchema(), uType, l, p, s, n, d, i, (Name) null, converter, binding, null);
}
// Other forced types are UDT's, enums, etc.
@ -314,7 +314,7 @@ public abstract class AbstractTypedElementDefinition<T extends Definition>
s = result.getScale();
String t = result.getType();
Name u = result.getQualifiedUserType();
result = new DefaultDataTypeDefinition(db, definedType.getSchema(), t, l, p, s, n, d, u, converter, binding, uType);
result = new DefaultDataTypeDefinition(db, definedType.getSchema(), t, l, p, s, n, d, i, u, converter, binding, uType);
}
// [#4597] If we don't have a type-rewrite (forcedDataType) or a

View File

@ -175,7 +175,7 @@ public class DefaultDataTypeDefinition implements DataTypeDefinition {
}
/**
* @deprecated - [#330] - 3.9.0 - Use {@link #DefaultDataTypeDefinition(Database, SchemaDefinition, String, Number, Number, Number, Boolean, String, Name, String, String, String)} instead.
* @deprecated - [#330] - 3.9.0 - Use {@link #DefaultDataTypeDefinition(Database, SchemaDefinition, String, Number, Number, Number, Boolean, String, Name, String, String, String)} instead.
*/
@Deprecated
public DefaultDataTypeDefinition(Database database, SchemaDefinition schema, String typeName, Number length, Number precision, Number scale, Boolean nullable, String defaultValue, String userType, String converter, String binding, String javaType) {
@ -183,6 +183,10 @@ public class DefaultDataTypeDefinition implements DataTypeDefinition {
}
public DefaultDataTypeDefinition(Database database, SchemaDefinition schema, String typeName, Number length, Number precision, Number scale, Boolean nullable, String defaultValue, Name userType, String converter, String binding, String javaType) {
this(database, schema, typeName, length, precision, scale, nullable, defaultValue, false, userType, converter, binding, javaType);
}
public DefaultDataTypeDefinition(Database database, SchemaDefinition schema, String typeName, Number length, Number precision, Number scale, Boolean nullable, String defaultValue, boolean isIdentity, Name userType, String converter, String binding, String javaType) {
this.database = database;
this.schema = schema;
@ -212,6 +216,7 @@ public class DefaultDataTypeDefinition implements DataTypeDefinition {
this.scale = scale == null ? 0 : scale.intValue();
this.nullable = nullable == null ? true : nullable.booleanValue();
this.defaultValue = defaultValue;
this.isIdentity = isIdentity;
}
@Override