[jOOQ/jOOQ#13073] Order of calling
DataType.asConvertedDataType(Converter) and DataType.getArrayDataType() should not matter
This commit is contained in:
parent
f9c58f9423
commit
91715af89b
77
jOOQ/src/main/java/org/jooq/ArrayComponentConverter.java
Normal file
77
jOOQ/src/main/java/org/jooq/ArrayComponentConverter.java
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
import org.jooq.impl.AbstractConverter;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
final class ArrayComponentConverter<T, U> extends AbstractConverter<T, U> {
|
||||
|
||||
private final Converter<T[], U[]> converter;
|
||||
|
||||
public ArrayComponentConverter(Converter<T[], U[]> converter) {
|
||||
super((Class<T>) converter.fromType().getComponentType(), (Class<U>) converter.toType().getComponentType());
|
||||
|
||||
this.converter = converter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final U from(T t) {
|
||||
if (t == null)
|
||||
return null;
|
||||
|
||||
T[] a = (T[]) Array.newInstance(fromType(), 1);
|
||||
a[0] = t;
|
||||
return converter.from(a)[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T to(U u) {
|
||||
if (u == null)
|
||||
return null;
|
||||
|
||||
U[] a = (U[]) Array.newInstance(fromType(), 1);
|
||||
a[0] = u;
|
||||
return converter.to(a)[0];
|
||||
}
|
||||
}
|
||||
72
jOOQ/src/main/java/org/jooq/ArrayConverter.java
Normal file
72
jOOQ/src/main/java/org/jooq/ArrayConverter.java
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.impl.Internal.arrayType;
|
||||
|
||||
import org.jooq.impl.AbstractConverter;
|
||||
import org.jooq.tools.Convert;
|
||||
|
||||
/**
|
||||
* A {@link Converter} that can convert arrays based on a delegate converter
|
||||
* that can convert the array base types.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class ArrayConverter<T, U> extends AbstractConverter<T[], U[]> {
|
||||
|
||||
final Converter<T, U> converter;
|
||||
final Converter<U, T> inverse;
|
||||
|
||||
public ArrayConverter(Converter<T, U> converter) {
|
||||
super(arrayType(converter.fromType()), arrayType(converter.toType()));
|
||||
|
||||
this.converter = converter;
|
||||
this.inverse = Converters.inverse(converter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final U[] from(T[] t) {
|
||||
return Convert.convertArray(t, converter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T[] to(U[] t) {
|
||||
return Convert.convertArray(t, inverse);
|
||||
}
|
||||
}
|
||||
@ -37,9 +37,6 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.impl.Internal.arrayType;
|
||||
import static org.jooq.tools.Convert.convertArray;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.function.Function;
|
||||
|
||||
@ -132,15 +129,26 @@ public class Converters<T, U> extends AbstractConverter<T, U> {
|
||||
return Converter.of(converter.toType(), converter.fromType(), converter::to, converter::from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a converter that can convert arrays with the component types being
|
||||
* the argument converter's types.
|
||||
*/
|
||||
public static <T, U> Converter<T[], U[]> forArrays(final Converter<T, U> converter) {
|
||||
final Converter<U, T> inverse = inverse(converter);
|
||||
|
||||
return Converter.of(arrayType(converter.fromType()), arrayType(converter.toType()),
|
||||
t -> convertArray(t, converter),
|
||||
u -> convertArray(u, inverse)
|
||||
);
|
||||
return new ArrayConverter<>(converter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a converter that can convert component types based on the argument
|
||||
* converter, which converts array types.
|
||||
*/
|
||||
public static <T, U> Converter<T, U> forArrayComponents(final Converter<T[], U[]> converter) {
|
||||
if (converter instanceof ArrayConverter)
|
||||
return ((ArrayConverter<T, U>) converter).converter;
|
||||
else
|
||||
return new ArrayComponentConverter<>(converter);
|
||||
}
|
||||
|
||||
|
||||
Converters(Converter... chain) {
|
||||
super(chain[0].fromType(), chain[chain.length - 1].toType());
|
||||
|
||||
|
||||
@ -526,7 +526,7 @@ implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataType<T[]> getArrayDataType() {
|
||||
public /* non-final */ DataType<T[]> getArrayDataType() {
|
||||
return new ArrayDataType<>(this);
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ 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;
|
||||
@ -55,6 +56,7 @@ import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.QOM.GenerationOption;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* A <code>DataType</code> used for converted types using {@link Converter}
|
||||
@ -132,6 +134,25 @@ final class ConvertedDataType<T, U> extends AbstractDataTypeX<U> {
|
||||
return (DataType<U>) delegate.getSQLDataType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataType<U[]> getArrayDataType() {
|
||||
return delegate.getArrayDataType().asConvertedDataType(Converters.forArrays(binding.converter()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataType<?> getArrayComponentDataType() {
|
||||
DataType<?> d = delegate.getArrayComponentDataType();
|
||||
|
||||
return d == null ? null : d.asConvertedDataType(Converters.forArrayComponents((Converter) binding.converter()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Class<?> getArrayComponentType() {
|
||||
DataType<?> d = getArrayComponentDataType();
|
||||
|
||||
return d == null ? null : d.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DataType<U> getDataType(Configuration configuration) {
|
||||
return (DataType<U>) delegate.getDataType(configuration);
|
||||
|
||||
@ -671,7 +671,12 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
// Type-specific subclasses API
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
abstract static class AbstractBinding<T, U> implements org.jooq.Binding<T, U> {
|
||||
/**
|
||||
* An internal binding class for default data type binding implementations.
|
||||
* <p>
|
||||
* This base class can be safely assumed to not leak into custom bindings.
|
||||
*/
|
||||
abstract static class InternalBinding<T, U> implements org.jooq.Binding<T, U> {
|
||||
static final Set<SQLDialect> NEEDS_PRECISION_SCALE_ON_BIGDECIMAL = SQLDialect.supportedBy(CUBRID, DERBY, FIREBIRD, H2, HSQLDB);
|
||||
static final Set<SQLDialect> REQUIRES_JSON_CAST = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
|
||||
static final Set<SQLDialect> NO_SUPPORT_ENUM_CAST = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
|
||||
@ -685,7 +690,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
final Converter<T, U> converter;
|
||||
final boolean attachable;
|
||||
|
||||
AbstractBinding(DataType<T> dataType, Converter<T, U> converter) {
|
||||
InternalBinding(DataType<T> dataType, Converter<T, U> converter) {
|
||||
this.dataType = dataType;
|
||||
this.converter = converter;
|
||||
|
||||
@ -1078,16 +1083,16 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DelegatingBinding<X, T, U> extends AbstractBinding<X, U> {
|
||||
static final class DelegatingBinding<X, T, U> extends InternalBinding<X, U> {
|
||||
|
||||
private final Converter<T, X> delegatingConverter;
|
||||
private final AbstractBinding<T, U> delegatingBinding;
|
||||
private final InternalBinding<T, U> delegatingBinding;
|
||||
|
||||
DelegatingBinding(
|
||||
DataType<X> originalDataType,
|
||||
Converter<T, X> delegatingConverter,
|
||||
Converter<X, U> originalConverter,
|
||||
Function<? super Converter<T, U>, ? extends AbstractBinding<T, U>> f
|
||||
Function<? super Converter<T, U>, ? extends InternalBinding<T, U>> f
|
||||
) {
|
||||
super(originalDataType, originalConverter);
|
||||
|
||||
@ -1141,7 +1146,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultArrayBinding<U> extends AbstractBinding<Object[], U> {
|
||||
static final class DefaultArrayBinding<U> extends InternalBinding<Object[], U> {
|
||||
private static final Set<SQLDialect> REQUIRES_ARRAY_CAST = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
|
||||
|
||||
|
||||
@ -1564,7 +1569,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
|
||||
|
||||
static final class DefaultBigDecimalBinding<U> extends AbstractBinding<BigDecimal, U> {
|
||||
static final class DefaultBigDecimalBinding<U> extends InternalBinding<BigDecimal, U> {
|
||||
private static final Set<SQLDialect> BIND_AS_STRING = SQLDialect.supportedBy(SQLITE);
|
||||
|
||||
DefaultBigDecimalBinding(DataType<BigDecimal> dataType, Converter<BigDecimal, U> converter) {
|
||||
@ -1625,7 +1630,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultBigIntegerBinding<U> extends AbstractBinding<BigInteger, U> {
|
||||
static final class DefaultBigIntegerBinding<U> extends InternalBinding<BigInteger, U> {
|
||||
private static final Set<SQLDialect> BIND_AS_STRING = SQLDialect.supportedBy(SQLITE);
|
||||
|
||||
DefaultBigIntegerBinding(DataType<BigInteger> dataType, Converter<BigInteger, U> converter) {
|
||||
@ -1689,7 +1694,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultBlobBinding<U> extends AbstractBinding<Blob, U> {
|
||||
static final class DefaultBlobBinding<U> extends InternalBinding<Blob, U> {
|
||||
|
||||
DefaultBlobBinding(DataType<Blob> dataType, Converter<Blob, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -1751,7 +1756,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultBooleanBinding<U> extends AbstractBinding<Boolean, U> {
|
||||
static final class DefaultBooleanBinding<U> extends InternalBinding<Boolean, U> {
|
||||
private static final Set<SQLDialect> BIND_AS_1_0 = SQLDialect.supportedBy(FIREBIRD, SQLITE);
|
||||
|
||||
|
||||
@ -1879,7 +1884,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultByteBinding<U> extends AbstractBinding<Byte, U> {
|
||||
static final class DefaultByteBinding<U> extends InternalBinding<Byte, U> {
|
||||
|
||||
DefaultByteBinding(DataType<Byte> dataType, Converter<Byte, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -1939,7 +1944,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultBytesBinding<U> extends AbstractBinding<byte[], U> {
|
||||
static final class DefaultBytesBinding<U> extends InternalBinding<byte[], U> {
|
||||
|
||||
// [#12956] Starting from H2 2.0, we can't use byte[] for BLOB anymore, if they're
|
||||
// larger than 1MB
|
||||
@ -2152,7 +2157,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultClobBinding<U> extends AbstractBinding<Clob, U> {
|
||||
static final class DefaultClobBinding<U> extends InternalBinding<Clob, U> {
|
||||
|
||||
DefaultClobBinding(DataType<Clob> dataType, Converter<Clob, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -2199,7 +2204,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultDateBinding<U> extends AbstractBinding<Date, U> {
|
||||
static final class DefaultDateBinding<U> extends InternalBinding<Date, U> {
|
||||
private static final Set<SQLDialect> INLINE_AS_STRING_LITERAL = SQLDialect.supportedBy(SQLITE);
|
||||
|
||||
DefaultDateBinding(DataType<Date> dataType, Converter<Date, U> converter) {
|
||||
@ -2393,7 +2398,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultDayToSecondBinding<U> extends AbstractBinding<DayToSecond, U> {
|
||||
static final class DefaultDayToSecondBinding<U> extends InternalBinding<DayToSecond, U> {
|
||||
private static final Set<SQLDialect> REQUIRE_PG_INTERVAL = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
|
||||
private static final Set<SQLDialect> REQUIRE_STANDARD_INTERVAL = SQLDialect.supportedBy(H2);
|
||||
|
||||
@ -2488,7 +2493,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultDoubleBinding<U> extends AbstractBinding<Double, U> {
|
||||
static final class DefaultDoubleBinding<U> extends InternalBinding<Double, U> {
|
||||
static final Set<SQLDialect> REQUIRES_LITERAL_CAST = SQLDialect.supportedBy(H2);
|
||||
|
||||
DefaultDoubleBinding(DataType<Double> dataType, Converter<Double, U> converter) {
|
||||
@ -2657,7 +2662,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultEnumTypeBinding<U> extends AbstractBinding<EnumType, U> {
|
||||
static final class DefaultEnumTypeBinding<U> extends InternalBinding<EnumType, U> {
|
||||
private static final Set<SQLDialect> REQUIRE_ENUM_CAST = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
|
||||
|
||||
DefaultEnumTypeBinding(DataType<EnumType> dataType, Converter<EnumType, U> converter) {
|
||||
@ -2748,7 +2753,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultFloatBinding<U> extends AbstractBinding<Float, U> {
|
||||
static final class DefaultFloatBinding<U> extends InternalBinding<Float, U> {
|
||||
|
||||
DefaultFloatBinding(DataType<Float> dataType, Converter<Float, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -2840,7 +2845,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultIntegerBinding<U> extends AbstractBinding<Integer, U> {
|
||||
static final class DefaultIntegerBinding<U> extends InternalBinding<Integer, U> {
|
||||
|
||||
DefaultIntegerBinding(DataType<Integer> dataType, Converter<Integer, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -2897,7 +2902,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultLongBinding<U> extends AbstractBinding<Long, U> {
|
||||
static final class DefaultLongBinding<U> extends InternalBinding<Long, U> {
|
||||
|
||||
DefaultLongBinding(DataType<Long> dataType, Converter<Long, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -3130,7 +3135,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultOffsetDateTimeBinding<U> extends AbstractBinding<OffsetDateTime, U> {
|
||||
static final class DefaultOffsetDateTimeBinding<U> extends InternalBinding<OffsetDateTime, U> {
|
||||
|
||||
DefaultOffsetDateTimeBinding(DataType<OffsetDateTime> dataType, Converter<OffsetDateTime, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -3321,7 +3326,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultOffsetTimeBinding<U> extends AbstractBinding<OffsetTime, U> {
|
||||
static final class DefaultOffsetTimeBinding<U> extends InternalBinding<OffsetTime, U> {
|
||||
|
||||
DefaultOffsetTimeBinding(DataType<OffsetTime> dataType, Converter<OffsetTime, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -3435,7 +3440,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultInstantBinding<U> extends AbstractBinding<Instant, U> {
|
||||
static final class DefaultInstantBinding<U> extends InternalBinding<Instant, U> {
|
||||
|
||||
private static final Converter<OffsetDateTime, Instant> CONVERTER = Converter.ofNullable(
|
||||
OffsetDateTime.class,
|
||||
@ -3493,7 +3498,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class CommercialOnlyBinding<U> extends AbstractBinding<Object, U> {
|
||||
static final class CommercialOnlyBinding<U> extends InternalBinding<Object, U> {
|
||||
CommercialOnlyBinding(DataType<Object> dataType, Converter<Object, U> converter) {
|
||||
super(dataType, converter);
|
||||
}
|
||||
@ -3532,7 +3537,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultOtherBinding<U> extends AbstractBinding<Object, U> {
|
||||
static final class DefaultOtherBinding<U> extends InternalBinding<Object, U> {
|
||||
|
||||
DefaultOtherBinding(DataType<Object> dataType, Converter<Object, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -3541,7 +3546,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
final void set0(BindingSetStatementContext<U> ctx, Object value) throws SQLException {
|
||||
AbstractBinding b = (AbstractBinding) binding(DefaultDataType.getDataType(ctx.dialect(), value.getClass()));
|
||||
InternalBinding b = (InternalBinding) binding(DefaultDataType.getDataType(ctx.dialect(), value.getClass()));
|
||||
|
||||
// [#7370] Prevent a stack overflow error on unsupported data types
|
||||
if (b instanceof DefaultOtherBinding)
|
||||
@ -3630,7 +3635,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultRowIdBinding<U> extends AbstractBinding<RowId, U> {
|
||||
static final class DefaultRowIdBinding<U> extends InternalBinding<RowId, U> {
|
||||
|
||||
DefaultRowIdBinding(DataType<RowId> dataType, Converter<RowId, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -3667,7 +3672,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultRecordBinding<U> extends AbstractBinding<Record, U> {
|
||||
static final class DefaultRecordBinding<U> extends InternalBinding<Record, U> {
|
||||
private static final Set<SQLDialect> REQUIRE_RECORD_CAST = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
|
||||
|
||||
DefaultRecordBinding(DataType<Record> dataType, Converter<Record, U> converter) {
|
||||
@ -3880,7 +3885,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
// which would cause a StackOverflowError, here!
|
||||
else if (type != converter.fromType()) {
|
||||
Converter<Object, T> c = (Converter<Object, T>) converter;
|
||||
return c.from(pgFromString(ctx, field("converted_field", ((ConvertedDataType<?, ?>) field.getDataType()).delegate), string));
|
||||
return c.from(pgFromString(ctx, field("converted_field", ((ConvertedDataType<?, ?>) field.getDataType()).delegate()), string));
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException("Class " + type + " is not supported");
|
||||
@ -3963,7 +3968,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultResultBinding<U> extends AbstractBinding<org.jooq.Result<?>, U> {
|
||||
static final class DefaultResultBinding<U> extends InternalBinding<org.jooq.Result<?>, U> {
|
||||
|
||||
DefaultResultBinding(DataType<Result<?>> dataType, Converter<Result<?>, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -4058,7 +4063,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultShortBinding<U> extends AbstractBinding<Short, U> {
|
||||
static final class DefaultShortBinding<U> extends InternalBinding<Short, U> {
|
||||
|
||||
DefaultShortBinding(DataType<Short> dataType, Converter<Short, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -4115,7 +4120,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultStringBinding<U> extends AbstractBinding<String, U> {
|
||||
static final class DefaultStringBinding<U> extends InternalBinding<String, U> {
|
||||
|
||||
DefaultStringBinding(DataType<String> dataType, Converter<String, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -4195,7 +4200,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultNStringBinding<U> extends AbstractBinding<String, U> {
|
||||
static final class DefaultNStringBinding<U> extends InternalBinding<String, U> {
|
||||
private final DefaultStringBinding<U> fallback;
|
||||
|
||||
DefaultNStringBinding(DataType<String> dataType, Converter<String, U> converter) {
|
||||
@ -4290,7 +4295,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultTimeBinding<U> extends AbstractBinding<Time, U> {
|
||||
static final class DefaultTimeBinding<U> extends InternalBinding<Time, U> {
|
||||
|
||||
DefaultTimeBinding(DataType<Time> dataType, Converter<Time, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -4403,7 +4408,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultTimestampBinding<U> extends AbstractBinding<Timestamp, U> {
|
||||
static final class DefaultTimestampBinding<U> extends InternalBinding<Timestamp, U> {
|
||||
private static final Set<SQLDialect> INLINE_AS_STRING_LITERAL = SQLDialect.supportedBy(SQLITE);
|
||||
|
||||
DefaultTimestampBinding(DataType<Timestamp> dataType, Converter<Timestamp, U> converter) {
|
||||
@ -4510,7 +4515,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultUUIDBinding<U> extends AbstractBinding<UUID, U> {
|
||||
static final class DefaultUUIDBinding<U> extends InternalBinding<UUID, U> {
|
||||
|
||||
DefaultUUIDBinding(DataType<UUID> dataType, Converter<UUID, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -5230,7 +5235,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
|
||||
|
||||
static final class DefaultJSONBinding<U> extends AbstractBinding<JSON, U> {
|
||||
static final class DefaultJSONBinding<U> extends InternalBinding<JSON, U> {
|
||||
|
||||
DefaultJSONBinding(DataType<JSON> dataType, Converter<JSON, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -5296,7 +5301,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultJSONBBinding<U> extends AbstractBinding<org.jooq.JSONB, U> {
|
||||
static final class DefaultJSONBBinding<U> extends InternalBinding<org.jooq.JSONB, U> {
|
||||
static final Set<SQLDialect> EMULATE_AS_BLOB = SQLDialect.supportedBy(DERBY, FIREBIRD, HSQLDB, SQLITE);
|
||||
|
||||
DefaultJSONBBinding(DataType<JSONB> dataType, Converter<JSONB, U> converter) {
|
||||
@ -5398,7 +5403,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultXMLBinding<U> extends AbstractBinding<XML, U> {
|
||||
static final class DefaultXMLBinding<U> extends InternalBinding<XML, U> {
|
||||
|
||||
DefaultXMLBinding(DataType<XML> dataType, Converter<XML, U> converter) {
|
||||
super(dataType, converter);
|
||||
@ -5448,7 +5453,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultYearToSecondBinding<U> extends AbstractBinding<YearToSecond, U> {
|
||||
static final class DefaultYearToSecondBinding<U> extends InternalBinding<YearToSecond, U> {
|
||||
private static final Set<SQLDialect> REQUIRE_PG_INTERVAL = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
|
||||
|
||||
DefaultYearToSecondBinding(DataType<YearToSecond> dataType, Converter<YearToSecond, U> converter) {
|
||||
@ -5528,7 +5533,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
static final class DefaultYearToMonthBinding<U> extends AbstractBinding<YearToMonth, U> {
|
||||
static final class DefaultYearToMonthBinding<U> extends InternalBinding<YearToMonth, U> {
|
||||
private static final Set<SQLDialect> REQUIRE_PG_INTERVAL = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
|
||||
private static final Set<SQLDialect> REQUIRE_STANDARD_INTERVAL = SQLDialect.supportedBy(H2);
|
||||
|
||||
|
||||
@ -111,6 +111,7 @@ import org.jooq.QualifiedRecord;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.exception.MappingException;
|
||||
import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
import org.jooq.impl.DefaultBinding.InternalBinding;
|
||||
import org.jooq.impl.QOM.GenerationOption;
|
||||
import org.jooq.types.UByte;
|
||||
import org.jooq.types.UInteger;
|
||||
@ -456,7 +457,7 @@ public class DefaultDataType<T> extends AbstractDataTypeX<T> {
|
||||
|
||||
// [#10362] User bindings and/or converters need to be retained
|
||||
this.binding =
|
||||
t.getBinding() instanceof org.jooq.impl.DefaultBinding.AbstractBinding
|
||||
t.getBinding() instanceof InternalBinding
|
||||
? binding(this, (Converter<T, T>) t.getBinding().converter())
|
||||
: t.getBinding();
|
||||
}
|
||||
|
||||
@ -39,6 +39,11 @@ package org.jooq.impl;
|
||||
|
||||
import org.jooq.Converter;
|
||||
|
||||
/**
|
||||
* A converter that doesn't convert anything.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public final class IdentityConverter<T> implements Converter<T, T> {
|
||||
private final Class<T> type;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user