[jOOQ/jOOQ#10060] Avoid escaping of nested JSON content in MySQL
This commit is contained in:
parent
3ce7931a61
commit
2afcfe084f
@ -45,6 +45,7 @@ import static org.jooq.impl.JSONObject.acceptJSONNullClause;
|
||||
import static org.jooq.impl.Names.N_JSONB_AGG;
|
||||
import static org.jooq.impl.Names.N_JSON_AGG;
|
||||
import static org.jooq.impl.Names.N_JSON_ARRAYAGG;
|
||||
import static org.jooq.impl.Names.N_JSON_MERGE;
|
||||
import static org.jooq.impl.SQLDataType.JSON;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -80,17 +81,16 @@ implements JSONArrayAggOrderByStep<J> {
|
||||
public void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
|
||||
// Workaround for https://jira.mariadb.org/browse/MDEV-21914
|
||||
if (!Tools.isEmpty(withinGroupOrderBy))
|
||||
ctx.visit(DSL.concat(inline('['), groupConcat(arguments.get(0)).orderBy(withinGroupOrderBy), inline(']')));
|
||||
|
||||
// Workaround for https://jira.mariadb.org/browse/MDEV-21912
|
||||
else
|
||||
ctx.visit(DSL.concat(inline('['), groupConcat(arguments.get(0)), inline(']')));
|
||||
case MYSQL: {
|
||||
// Workaround for https://jira.mariadb.org/browse/MDEV-21912,
|
||||
// https://jira.mariadb.org/browse/MDEV-21914, and other issues
|
||||
Field<?> concat = Tools.isEmpty(withinGroupOrderBy)
|
||||
? DSL.concat(inline('['), groupConcat(arguments.get(0)), inline(']'))
|
||||
: DSL.concat(inline('['), groupConcat(arguments.get(0)).orderBy(withinGroupOrderBy), inline(']'));
|
||||
|
||||
ctx.visit(N_JSON_MERGE).sql('(').visit(inline("[]")).sql(", ").visit(concat).sql(')');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -119,6 +119,7 @@ final class Names {
|
||||
static final Name N_JSON_ARRAYAGG = unquotedName("json_arrayagg");
|
||||
static final Name N_JSON_CONTAINS_PATH = unquotedName("json_contains_path");
|
||||
static final Name N_JSON_EXTRACT = unquotedName("json_extract");
|
||||
static final Name N_JSON_MERGE = unquotedName("json_merge");
|
||||
static final Name N_JSON_OBJECT = unquotedName("json_object");
|
||||
static final Name N_JSON_OBJECT_AGG = unquotedName("json_object_agg");
|
||||
static final Name N_JSON_OBJECTAGG = unquotedName("json_objectagg");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user