[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 first column value in the bulk set.
This commit is contained in:
parent
4d6bbc902b
commit
9c5980a7df
@ -37,7 +37,11 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
// ...
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
@ -59,6 +63,11 @@ abstract class AbstractStoreQuery<R extends Record> extends AbstractDMLQuery<R>
|
||||
*/
|
||||
private static final long serialVersionUID = 6864591335823160569L;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AbstractStoreQuery(Configuration configuration, WithImpl with, Table<R> table) {
|
||||
super(configuration, with, table);
|
||||
}
|
||||
@ -85,22 +94,50 @@ abstract class AbstractStoreQuery<R extends Record> extends AbstractDMLQuery<R>
|
||||
|
||||
final <T> void addValue(Field<T> field, int index, T value) {
|
||||
if (field == null)
|
||||
if (index >= 0)
|
||||
addValue(new UnknownField<T>(index), value);
|
||||
else
|
||||
addValue(new UnknownField<T>(getValues().size()), value);
|
||||
addUnknownValue(index, value);
|
||||
else
|
||||
getValues().put(field, Tools.field(value, field));
|
||||
addKnownValue(field, value);
|
||||
}
|
||||
|
||||
private final <T> void addUnknownValue(int index, T value) {
|
||||
if (index >= 0)
|
||||
addValue(new UnknownField<T>(index), value);
|
||||
else
|
||||
addValue(new UnknownField<T>(getValues().size()), value);
|
||||
}
|
||||
|
||||
private final <T> void addKnownValue(Field<T> field, T value) {
|
||||
addKnownValue(field, Tools.field(value, field));
|
||||
}
|
||||
|
||||
final <T> void addValue(Field<T> field, int index, Field<T> value) {
|
||||
if (field == null)
|
||||
if (index >= 0)
|
||||
addValue(new UnknownField<T>(index), value);
|
||||
else
|
||||
addValue(new UnknownField<T>(getValues().size()), value);
|
||||
addUnknownValue(index, value);
|
||||
else
|
||||
getValues().put(field, Tools.field(value, field));
|
||||
addKnownValue(field, value);
|
||||
}
|
||||
|
||||
private final <T> void addUnknownValue(int index, Field<T> value) {
|
||||
if (index >= 0)
|
||||
addValue(new UnknownField<T>(index), value);
|
||||
else
|
||||
addValue(new UnknownField<T>(getValues().size()), value);
|
||||
}
|
||||
|
||||
private final <T> void addKnownValue(Field<T> field, Field<T> value) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
getValues().put(field, value);
|
||||
}
|
||||
|
||||
static class UnknownField<T> extends AbstractField<T> {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user