From 748ec932832b0f7b43864ce7b5fd03e0aee7f7a5 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Thu, 23 Jul 2020 17:41:04 +0200 Subject: [PATCH] [jOOQ/jOOQ#10438] Support lazy conversion of built-in data types --- jOOQ/src/main/java/org/jooq/impl/Val.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/Val.java b/jOOQ/src/main/java/org/jooq/impl/Val.java index 802ff93def..07c9ac4d38 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Val.java +++ b/jOOQ/src/main/java/org/jooq/impl/Val.java @@ -82,7 +82,12 @@ final class Val extends AbstractParam { */ @SuppressWarnings({ "rawtypes", "unchecked" }) final Val convertTo(DataType type) { + + // [#10438] A user defined data type could was not provided explicitly, + // when wrapping a bind value in DSL::val or DSL::inline if (getDataType() instanceof DataTypeProxy) { + + // [#9492] Maintain legacy static type registry behaviour for now if (((DataTypeProxy) getDataType()).type instanceof LegacyConvertedDataType && type == SQLDataType.OTHER) { type = (DataType) ((DataTypeProxy) getDataType()).type; @@ -90,14 +95,22 @@ final class Val extends AbstractParam { log.warn("Deprecation", "User-defined, converted data type " + type.getType() + " was registered statically, which will be unsupported in the future, see https://github.com/jOOQ/jOOQ/issues/9492. Please use explicit data types in generated code, or e.g. with DSL.val(Object, DataType), or DSL.inline(Object, DataType).", new SQLWarning("Static type registry usage")); } - Val w = new Val<>(type.convert(getValue()), type, getParamName()); - w.setInline(isInline()); - return w; + return convertTo0(type); } + + // [#10438] A data type conversion between built in data types was made + else if (type instanceof ConvertedDataType) + return convertTo0(type); else return (Val) this; } + private final Val convertTo0(DataType type) { + Val w = new Val<>(type.convert(getValue()), type, getParamName()); + w.setInline(isInline()); + return w; + } + @Override public void accept(Context ctx) { if (EmbeddableRecord.class.isAssignableFrom(getType())) {