[jOOQ/jOOQ#10312] Converted datatype not using type from dialect after calling nullable
This commit is contained in:
parent
271d4ce311
commit
65582520bd
@ -47,66 +47,154 @@ import org.jooq.BindingRegisterContext;
|
||||
import org.jooq.BindingSQLContext;
|
||||
import org.jooq.BindingSetSQLOutputContext;
|
||||
import org.jooq.BindingSetStatementContext;
|
||||
import org.jooq.CharacterSet;
|
||||
import org.jooq.Collation;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Converter;
|
||||
import org.jooq.Converters;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Nullability;
|
||||
import org.jooq.SQLDialect;
|
||||
|
||||
/**
|
||||
* A <code>DataType</code> used for converted types using {@link Converter}
|
||||
*
|
||||
* @author Lukas Eder
|
||||
* @deprecated - 3.6.0 - [#3889] - Remove this type, it should not be needed any
|
||||
* longer
|
||||
*/
|
||||
@Deprecated
|
||||
final class ConvertedDataType<T, U> extends DefaultDataType<U> {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
final class ConvertedDataType<T, U> extends AbstractDataType<U> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -2321926692580974126L;
|
||||
|
||||
private final DataType<T> delegate;
|
||||
private final AbstractDataType<T> delegate;
|
||||
private final Binding<? super T, U> binding;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ConvertedDataType(AbstractDataType<T> delegate, Binding<? super T, U> binding) {
|
||||
super(
|
||||
null,
|
||||
binding.converter().toType(),
|
||||
binding,
|
||||
delegate.getQualifiedName(),
|
||||
delegate.getTypeName(),
|
||||
delegate.getCastTypeName(),
|
||||
delegate.precisionDefined() ? delegate.precision() : null,
|
||||
delegate.scaleDefined() ? delegate.scale() : null,
|
||||
delegate.lengthDefined() ? delegate.length() : null,
|
||||
delegate.nullability(),
|
||||
(Field<U>) delegate.defaultValue()
|
||||
);
|
||||
super(delegate.getQualifiedName(), delegate.getCommentPart());
|
||||
|
||||
this.delegate = delegate;
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSQLType() {
|
||||
return delegate.getSQLType();
|
||||
AbstractDataType<U> construct(
|
||||
Integer newPrecision,
|
||||
Integer newScale,
|
||||
Integer newLength,
|
||||
Nullability newNullability,
|
||||
Collation newCollation,
|
||||
CharacterSet newCharacterSet,
|
||||
boolean newIdentity,
|
||||
Field<U> newDefaultValue
|
||||
) {
|
||||
return (AbstractDataType) delegate.construct(
|
||||
newPrecision,
|
||||
newScale,
|
||||
newLength,
|
||||
newNullability,
|
||||
newCollation,
|
||||
newCharacterSet,
|
||||
newIdentity,
|
||||
(Field) newDefaultValue
|
||||
).asConvertedDataType(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName(Configuration configuration) {
|
||||
return delegate.getTypeName(configuration);
|
||||
public final DataType<U> getSQLDataType() {
|
||||
return (DataType<U>) delegate.getSQLDataType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCastTypeName(Configuration configuration) {
|
||||
return delegate.getCastTypeName(configuration);
|
||||
public final DataType<U> getDataType(Configuration configuration) {
|
||||
return (DataType<U>) delegate.getDataType(configuration);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public U convert(Object object) {
|
||||
public final Binding<?, U> getBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Class<U> getType() {
|
||||
return binding.converter().toType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SQLDialect getDialect() {
|
||||
return delegate.getDialect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Nullability nullability() {
|
||||
return delegate.nullability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Collation collation() {
|
||||
return delegate.collation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CharacterSet characterSet() {
|
||||
return delegate.characterSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean identity() {
|
||||
return delegate.identity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<U> default_() {
|
||||
return (Field<U>) delegate.default_();
|
||||
}
|
||||
|
||||
@Override
|
||||
final String typeName0() {
|
||||
return delegate.typeName0();
|
||||
}
|
||||
|
||||
@Override
|
||||
final String castTypePrefix0() {
|
||||
return delegate.castTypePrefix0();
|
||||
}
|
||||
|
||||
@Override
|
||||
final String castTypeSuffix0() {
|
||||
return delegate.castTypeSuffix0();
|
||||
}
|
||||
|
||||
@Override
|
||||
final String castTypeName0() {
|
||||
return delegate.castTypeName0();
|
||||
}
|
||||
|
||||
@Override
|
||||
final Class<?> tType0() {
|
||||
return delegate.tType0();
|
||||
}
|
||||
|
||||
@Override
|
||||
final Integer precision0() {
|
||||
return delegate.precision0();
|
||||
}
|
||||
|
||||
@Override
|
||||
final Integer scale0() {
|
||||
return delegate.scale0();
|
||||
}
|
||||
|
||||
@Override
|
||||
final Integer length0() {
|
||||
return delegate.length0();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final U convert(Object object) {
|
||||
if (getConverter().toType().isInstance(object))
|
||||
return (U) object;
|
||||
|
||||
@ -115,9 +203,8 @@ final class ConvertedDataType<T, U> extends DefaultDataType<U> {
|
||||
return ((Converter<T, U>) getConverter()).from(delegate.convert(object));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public <X> DataType<X> asConvertedDataType(Converter<? super U, X> converter) {
|
||||
public final <X> DataType<X> asConvertedDataType(Converter<? super U, X> converter) {
|
||||
return super.asConvertedDataType(new ChainedConverterBinding(getBinding(), converter));
|
||||
}
|
||||
|
||||
@ -183,4 +270,4 @@ final class ConvertedDataType<T, U> extends DefaultDataType<U> {
|
||||
delegate.get(ctx.convert(suffix));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user