[jOOQ/jOOQ#12549] Wrong JSON_MERGE_PRESERVE function generated when embedding JSON in MULTISET in MariaDB and MySQL

This commit is contained in:
Lukas Eder 2021-10-22 17:59:17 +02:00
parent 57cabbb05a
commit f7a86f1cdd

View File

@ -64,6 +64,7 @@ import static org.jooq.impl.JSONEntryImpl.isJSON;
import static org.jooq.impl.Keywords.K_MULTISET;
import static org.jooq.impl.Names.N_JSON_MERGE;
import static org.jooq.impl.Names.N_JSON_MERGE_PRESERVE;
import static org.jooq.impl.Names.N_JSON_QUERY;
import static org.jooq.impl.Names.N_MULTISET;
import static org.jooq.impl.Names.N_RECORD;
import static org.jooq.impl.Names.N_RESULT;
@ -391,12 +392,13 @@ final class Multiset<R extends Record> extends AbstractField<Result<R>> implemen
private static final Field<?> jsonMerge(Scope scope, String empty, Field<?> field) {
// [#12168] Yet another MariaDB JSON un-escaping workaround https://jira.mariadb.org/browse/MDEV-26134
// [#12549] Using JSON_MERGE_PRESERVE doesn't work here, as we might not know the user content
return REQUIRE_JSON_MERGE.contains(scope.dialect()) && isJSON(scope, field.getDataType())
? function(
SUPPORT_JSON_MERGE_PRESERVE.contains(scope.dialect()) ? N_JSON_MERGE_PRESERVE : N_JSON_MERGE,
N_JSON_QUERY,
field.getDataType(),
inline(empty),
field
field,
inline("$")
)
: field;
}