[jOOQ/jOOQ#14105] ClassCastException when nesting array(select) projections
This commit is contained in:
parent
30568537fd
commit
da12147ca7
@ -44,8 +44,8 @@ import org.jooq.Converter;
|
||||
*/
|
||||
public abstract class AbstractConverter<T, U> implements Converter<T, U> {
|
||||
|
||||
private final Class<T> fromType;
|
||||
private final Class<U> toType;
|
||||
private final Class<T> fromType;
|
||||
private final Class<U> toType;
|
||||
|
||||
public AbstractConverter(Class<T> fromType, Class<U> toType) {
|
||||
this.fromType = fromType;
|
||||
|
||||
@ -320,5 +320,9 @@ final class ConvertedDataType<T, U> extends AbstractDataTypeX<U> {
|
||||
final DataType<T> delegate() {
|
||||
return delegate instanceof ConvertedDataType c ? c.delegate() : delegate;
|
||||
}
|
||||
|
||||
static final DataType<?> delegate(DataType<?> type) {
|
||||
return type instanceof ConvertedDataType<?, ?> c ? c.delegate() : type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4007,9 +4007,8 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
// [#4964] [#6058] Recurse only if we have a meaningful converter, not the identity converter,
|
||||
// which would cause a StackOverflowError, here!
|
||||
else if (type != wrapper(converter.toType())) {
|
||||
return converter.from((T) pgFromString(ctx, field("converted_field", ((ConvertedDataType<?, ?>) field.getDataType()).delegate()), string), ctx.converterContext());
|
||||
}
|
||||
else if (type != wrapper(converter.toType()))
|
||||
return converter.from((T) pgFromString(ctx, field("converted_field", ConvertedDataType.delegate(field.getDataType())), string), ctx.converterContext());
|
||||
|
||||
throw new UnsupportedOperationException("Class " + type + " is not supported");
|
||||
}
|
||||
@ -4063,9 +4062,6 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
/**
|
||||
* Create an array from a String
|
||||
* <p>
|
||||
* Unfortunately, this feature is very poorly documented and true UDT
|
||||
* support by the PostGreSQL JDBC driver has been postponed for a long time.
|
||||
*
|
||||
* @param string A String representation of an array
|
||||
* @return The converted array
|
||||
@ -4074,10 +4070,11 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
if (string == null)
|
||||
return null;
|
||||
|
||||
DataType<?> t = field.getDataType();
|
||||
try {
|
||||
return Tools.map(
|
||||
toPGArray(string),
|
||||
v -> pgFromString(ctx, field("array_element", type.getComponentType()), v),
|
||||
v -> pgFromString(ctx, field("array_element", ConvertedDataType.delegate(t).getArrayComponentDataType()), v),
|
||||
size -> (Object[]) java.lang.reflect.Array.newInstance(type.getComponentType(), size)
|
||||
);
|
||||
}
|
||||
|
||||
@ -324,16 +324,11 @@ final class JSONEntryImpl<T> extends AbstractQueryPart implements JSONEntry<T>,
|
||||
}
|
||||
|
||||
static final boolean isType(DataType<?> t, Class<?> type) {
|
||||
if (t instanceof ConvertedDataType<?, ?> c)
|
||||
t = c.delegate();
|
||||
|
||||
return t.getType() == type;
|
||||
return ConvertedDataType.delegate(t).getType() == type;
|
||||
}
|
||||
|
||||
static final boolean isJSON(Context<?> ctx, DataType<?> type) {
|
||||
DataType<?> t = type instanceof ConvertedDataType<?, ?> c
|
||||
? c.delegate()
|
||||
: type;
|
||||
DataType<?> t = ConvertedDataType.delegate(type);
|
||||
|
||||
return t.isJSON()
|
||||
|| t.isEmbeddable() && forceMultisetContent(ctx, () -> t.getRow().size() > 1) && emulateMultisetWithJSON(ctx)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user