[jOOQ/jOOQ#8950] Workaround https://jira.mariadb.org/browse/MDEV-13701
This commit is contained in:
parent
0f3a641588
commit
70a293d1f9
@ -43,6 +43,7 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.asterisk;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.jsonObject;
|
||||
import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.unquotedName;
|
||||
@ -53,6 +54,7 @@ import static org.jooq.impl.Keywords.K_ABSENT;
|
||||
import static org.jooq.impl.Keywords.K_JSON_OBJECT;
|
||||
import static org.jooq.impl.Keywords.K_NULL;
|
||||
import static org.jooq.impl.Keywords.K_ON;
|
||||
import static org.jooq.impl.Names.N_JSON_MERGE;
|
||||
import static org.jooq.impl.Names.N_JSON_OBJECT;
|
||||
import static org.jooq.impl.Names.N_T;
|
||||
|
||||
@ -173,25 +175,48 @@ final class JSONObject<J> extends AbstractField<J> implements JSONObjectNullStep
|
||||
|
||||
|
||||
|
||||
default:
|
||||
ctx.visit(K_JSON_OBJECT).sql('(').visit(args);
|
||||
|
||||
// Workaround for https://github.com/h2database/h2database/issues/2496
|
||||
if (args.isEmpty() && ctx.family() == H2)
|
||||
ctx.visit(K_NULL).sql(' ').visit(K_ON).sql(' ').visit(K_NULL);
|
||||
|
||||
|
||||
case MARIADB:
|
||||
|
||||
// Workaround for https://jira.mariadb.org/browse/MDEV-13701
|
||||
if (args.size() > 1) {
|
||||
ctx.visit(N_JSON_MERGE).sql('(').visit(inline("{}"))
|
||||
.formatIndentStart();
|
||||
|
||||
for (JSONEntry<?> entry : args)
|
||||
ctx.sql(',').formatSeparator().visit(jsonObject(entry));
|
||||
|
||||
ctx.formatIndentEnd()
|
||||
.formatNewLine()
|
||||
.sql(')');
|
||||
}
|
||||
else
|
||||
acceptJSONNullClause(ctx, nullClause);
|
||||
acceptStandard(ctx);
|
||||
|
||||
ctx.sql(')');
|
||||
break;
|
||||
|
||||
default:
|
||||
acceptStandard(ctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private final void acceptStandard(Context<?> ctx) {
|
||||
ctx.visit(K_JSON_OBJECT).sql('(').visit(args);
|
||||
|
||||
// Workaround for https://github.com/h2database/h2database/issues/2496
|
||||
if (args.isEmpty() && ctx.family() == H2)
|
||||
ctx.visit(K_NULL).sql(' ').visit(K_ON).sql(' ').visit(K_NULL);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
else
|
||||
acceptJSONNullClause(ctx, nullClause);
|
||||
|
||||
ctx.sql(')');
|
||||
}
|
||||
|
||||
static final void acceptJSONNullClause(Context<?> ctx, JSONNullClause nullClause) {
|
||||
if (!NO_SUPPORT_ABSENT_ON_NULL.contains(ctx.dialect()))
|
||||
if (nullClause == NULL_ON_NULL)
|
||||
|
||||
@ -42,6 +42,7 @@ import static org.jooq.Clause.CONDITION_OVERLAPS;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
// ...
|
||||
// ...
|
||||
|
||||
Loading…
Reference in New Issue
Block a user