[jOOQ/jOOQ#11025] Wrong variable binding for boolean values in Oracle JSON_OBJECT(), JSON_ARRAY() and others

This commit is contained in:
Lukas Eder 2020-11-25 10:10:28 +01:00
parent 1cac6fb4a6
commit 26a5427188
2 changed files with 25 additions and 5 deletions

View File

@ -38,6 +38,7 @@
package org.jooq.impl;
import static org.jooq.impl.DSL.coalesce;
import static org.jooq.impl.DSL.field;
import static org.jooq.impl.Keywords.K_FORMAT;
import static org.jooq.impl.Keywords.K_JSON;
import static org.jooq.impl.Keywords.K_KEY;
@ -51,6 +52,7 @@ import org.jooq.DataType;
import org.jooq.Field;
import org.jooq.JSONEntry;
import org.jooq.JSONEntryValueStep;
// ...
import org.jooq.Record1;
import org.jooq.Select;
@ -147,17 +149,35 @@ final class JSONEntryImpl<T> extends AbstractQueryPart implements JSONEntry<T>,
}
static final Field<?> jsonCast(Context<?> ctx, Field<?> field) {
DataType<?> type = field.getDataType();
switch (ctx.family()) {
// [#10769] Some dialects don't support auto conversions from X to JSON
case H2: {
DataType<?> type = field.getDataType();
case H2:
if (type.getType() == UUID.class)
return field.cast(VARCHAR(36));
}
break;
}
return field;
}
}

View File

@ -110,7 +110,7 @@ final class Val<T> extends AbstractParam<T> {
return w;
}
private final <U> Val<U> convertTo0(DataType<U> type) {
final <U> Val<U> convertTo0(DataType<U> type) {
Val<U> w = new Val<>(type.convert(getValue()), type, getParamName());
w.setInline(isInline());
return w;