From c6eaa9ef3c1699a8c0ce7fd25d31471b777d7261 Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Thu, 15 Aug 2019 15:18:22 +0200 Subject: [PATCH] [jOOQ/jOOQ#8964] Fix bulk INSERT of DECIMAL with scale values SQL Server has a bug when it comes to bulk inserting DECIMAL with scale values (see https://github.com/microsoft/mssql-jdbc/issues/1021 for details). As a workaround jOOQ will in this scenario explicitly cast the corresponding column values in the bulk set. --- .../main/java/org/jooq/impl/FieldMapsForInsert.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/jOOQ/src/main/java/org/jooq/impl/FieldMapsForInsert.java b/jOOQ/src/main/java/org/jooq/impl/FieldMapsForInsert.java index 90e5b02ee0..dfe2e6305d 100644 --- a/jOOQ/src/main/java/org/jooq/impl/FieldMapsForInsert.java +++ b/jOOQ/src/main/java/org/jooq/impl/FieldMapsForInsert.java @@ -41,6 +41,7 @@ import static java.lang.Boolean.TRUE; import static org.jooq.Clause.FIELD_ROW; import static org.jooq.Clause.INSERT_SELECT; import static org.jooq.Clause.INSERT_VALUES; +// ... import static org.jooq.impl.DSL.name; import static org.jooq.impl.DSL.table; import static org.jooq.impl.Keywords.K_DEFAULT_VALUES; @@ -61,10 +62,12 @@ import java.util.Map.Entry; import java.util.Set; import org.jooq.Context; +import org.jooq.DataType; import org.jooq.Field; import org.jooq.Param; // ... import org.jooq.Record; +import org.jooq.RenderContext; import org.jooq.Select; import org.jooq.Table; import org.jooq.impl.AbstractStoreQuery.UnknownField; @@ -243,6 +246,7 @@ final class FieldMapsForInsert extends AbstractQueryPart { final void toSQL92Values(Context ctx, boolean emulateBulkInsertReturning) { boolean indent = (values.size() > 1); + boolean castFirstRowNumericValues = false ; for (int row = 0; row < rows ; row++) { if (row > 0) @@ -267,6 +271,14 @@ final class FieldMapsForInsert extends AbstractQueryPart { + + + + + + + + ctx.visit(list.get(row)); separator = ", "; }