From c2c838bf8614372e3798df5733c5eeee570dc224 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 23 Aug 2013 17:55:43 +0200 Subject: [PATCH] [#2708] Wrong SQL rendered for CAST(x AS DECIMAL(y, z)). Precision and scale are lost. --- .../src/main/java/org/jooq/impl/DefaultDataType.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java index 0fd98242f6..43fb1b9a0a 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java @@ -390,13 +390,17 @@ public class DefaultDataType implements DataType { // If this is a SQLDataType find the most suited dialect-specific // data type if (getDialect() == null) { + DataType dataType = TYPES_BY_SQL_DATATYPE[configuration.dialect().family().ordinal()] - // Be sure to reset length, precision, and scale, as those values - // were not registered in the below cache - DataType dataType = TYPES_BY_SQL_DATATYPE[configuration.dialect().family().ordinal()].get(length(0).precision(0, 0)); + // Be sure to reset length, precision, and scale, as those values + // were not registered in the below cache + .get(length(0).precision(0, 0)); if (dataType != null) { - return (DataType) dataType; + + // ... and then, set them back to the original value + // [#2710] TODO: Remove this logic along with cached data types + return (DataType) dataType.length(length).precision(precision, scale); } }