[jOOQ/jOOQ#12399] FOR JSON emulation must use RETURNING CLOB in Oracle
This commit is contained in:
parent
3409423a0a
commit
083fd06fc9
@ -86,6 +86,7 @@ import static org.jooq.impl.DSL.using;
|
||||
import static org.jooq.impl.DefaultBinding.DefaultDoubleBinding.REQUIRES_LITERAL_CAST;
|
||||
import static org.jooq.impl.DefaultBinding.DefaultDoubleBinding.infinity;
|
||||
import static org.jooq.impl.DefaultBinding.DefaultDoubleBinding.nan;
|
||||
import static org.jooq.impl.DefaultBinding.DefaultJSONBBinding.EMULATE_AS_BLOB;
|
||||
import static org.jooq.impl.DefaultExecuteContext.localTargetConnection;
|
||||
import static org.jooq.impl.Internal.arrayType;
|
||||
import static org.jooq.impl.Keywords.K_ARRAY;
|
||||
@ -143,6 +144,8 @@ import static org.jooq.util.postgres.PostgresUtils.toPGArray;
|
||||
import static org.jooq.util.postgres.PostgresUtils.toPGArrayString;
|
||||
import static org.jooq.util.postgres.PostgresUtils.toPGInterval;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.Modifier;
|
||||
@ -3818,8 +3821,14 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
case JSON:
|
||||
case JSONB: {
|
||||
String s = ctx.resultSet().getString(ctx.index());
|
||||
return s == null ? null : new JSONReader<>(ctx.dsl(), (AbstractRow<R>) type.getRow(), (Class<R>) type.getRecordType()).read(new StringReader(s), true);
|
||||
if (emulation == NestedCollectionEmulation.JSONB && EMULATE_AS_BLOB.contains(ctx.dialect())) {
|
||||
byte[] s = ctx.resultSet().getBytes(ctx.index());
|
||||
return s == null ? null : new JSONReader<>(ctx.dsl(), (AbstractRow<R>) type.getRow(), (Class<R>) type.getRecordType()).read(new InputStreamReader(new ByteArrayInputStream(s)), true);
|
||||
}
|
||||
else {
|
||||
String s = ctx.resultSet().getString(ctx.index());
|
||||
return s == null ? null : new JSONReader<>(ctx.dsl(), (AbstractRow<R>) type.getRow(), (Class<R>) type.getRecordType()).read(new StringReader(s), true);
|
||||
}
|
||||
}
|
||||
|
||||
case XML: {
|
||||
@ -4501,7 +4510,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
|
||||
static final class DefaultJSONBBinding<U> extends AbstractBinding<JSONB, U> {
|
||||
private static final Set<SQLDialect> EMULATE_AS_BLOB = SQLDialect.supportedBy(DERBY, FIREBIRD, HSQLDB, SQLITE);
|
||||
static final Set<SQLDialect> EMULATE_AS_BLOB = SQLDialect.supportedBy(DERBY, FIREBIRD, HSQLDB, SQLITE);
|
||||
|
||||
DefaultJSONBBinding(DataType<JSONB> dataType, Converter<JSONB, U> converter) {
|
||||
super(dataType, converter);
|
||||
|
||||
@ -44,6 +44,7 @@ import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.sql.Struct;
|
||||
import java.time.temporal.Temporal;
|
||||
import java.util.Calendar;
|
||||
@ -89,6 +90,7 @@ public final class DefaultConverterProvider implements ConverterProvider, Serial
|
||||
|| uWrapper == Optional.class
|
||||
|| uWrapper == String.class
|
||||
|| uWrapper == byte[].class
|
||||
|| uWrapper == ByteBuffer.class
|
||||
|| Number.class.isAssignableFrom(uWrapper) // No fail-fast implemented yet!
|
||||
|| Boolean.class.isAssignableFrom(uWrapper) // No fail-fast implemented yet!
|
||||
|| Character.class.isAssignableFrom(uWrapper)
|
||||
|
||||
@ -62,7 +62,6 @@ import static org.jooq.impl.Tools.BooleanDataKey.DATA_FORCE_CASE_ELSE_NULL;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Field;
|
||||
@ -71,6 +70,7 @@ import org.jooq.OrderField;
|
||||
// ...
|
||||
import org.jooq.Record;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Scope;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.SelectHavingStep;
|
||||
|
||||
@ -271,7 +271,7 @@ implements JSONArrayAggOrderByStep<J> {
|
||||
return (JSONArrayAgg<J>) super.orderBy(fields);
|
||||
}
|
||||
|
||||
static final <R extends Record> Select<R> patchOracleArrayAggBug(Configuration configuration, SelectHavingStep<R> select) {
|
||||
static final <R extends Record> Select<R> patchOracleArrayAggBug(Scope scope, SelectHavingStep<R> select) {
|
||||
|
||||
|
||||
|
||||
|
||||
@ -67,6 +67,7 @@ import static org.jooq.impl.Names.N_JSON_MERGE_PRESERVE;
|
||||
import static org.jooq.impl.Names.N_MULTISET;
|
||||
import static org.jooq.impl.Names.N_RECORD;
|
||||
import static org.jooq.impl.Names.N_RESULT;
|
||||
import static org.jooq.impl.SQLDataType.BLOB;
|
||||
import static org.jooq.impl.SQLDataType.CLOB;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.Tools.emulateMultiset;
|
||||
@ -169,7 +170,7 @@ final class Multiset<R extends Record> extends AbstractField<Result<R>> {
|
||||
returning = order.orderBy(t.fields());
|
||||
|
||||
Select<Record1<JSON>> s = patchOracleArrayAggBug(
|
||||
ctx.configuration(),
|
||||
ctx,
|
||||
select(DSL.coalesce(
|
||||
returningClob(ctx, returning),
|
||||
returningClob(ctx, jsonArray())
|
||||
@ -212,7 +213,7 @@ final class Multiset<R extends Record> extends AbstractField<Result<R>> {
|
||||
returning = order.orderBy(t.fields());
|
||||
|
||||
Select<Record1<JSONB>> s = patchOracleArrayAggBug(
|
||||
ctx.configuration(),
|
||||
ctx,
|
||||
select(DSL.coalesce(
|
||||
returningClob(ctx, returning),
|
||||
returningClob(ctx, jsonbArray())
|
||||
|
||||
@ -92,7 +92,6 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
@ -173,7 +172,7 @@ import static org.jooq.impl.Keywords.K_WHERE;
|
||||
import static org.jooq.impl.Keywords.K_WINDOW;
|
||||
import static org.jooq.impl.Keywords.K_WITH_CHECK_OPTION;
|
||||
import static org.jooq.impl.Keywords.K_WITH_READ_ONLY;
|
||||
import static org.jooq.impl.Names.N_DUAL;
|
||||
import static org.jooq.impl.Multiset.returningClob;
|
||||
import static org.jooq.impl.Names.N_LEVEL;
|
||||
import static org.jooq.impl.Names.N_ROWNUM;
|
||||
import static org.jooq.impl.QueryPartCollectionView.wrap;
|
||||
@ -182,7 +181,6 @@ import static org.jooq.impl.SQLDataType.JSONB;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.SQLDataType.XML;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.EMPTY_SORTFIELD;
|
||||
import static org.jooq.impl.Tools.aliased;
|
||||
import static org.jooq.impl.Tools.aliasedFields;
|
||||
import static org.jooq.impl.Tools.anyMatch;
|
||||
@ -240,8 +238,6 @@ import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.jooq.Asterisk;
|
||||
import org.jooq.Clause;
|
||||
@ -251,11 +247,11 @@ import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Fields;
|
||||
import org.jooq.ForeignKey;
|
||||
import org.jooq.GroupField;
|
||||
import org.jooq.JSONEntry;
|
||||
import org.jooq.JSONObjectNullStep;
|
||||
import org.jooq.JSONObjectReturningStep;
|
||||
import org.jooq.JoinType;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Operator;
|
||||
@ -267,6 +263,7 @@ import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Row;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Scope;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.SelectField;
|
||||
import org.jooq.SelectFieldOrAsterisk;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user