[jOOQ/jOOQ#14653] Support the JSON (VARIANT) data type

This commit is contained in:
Lukas Eder 2023-02-20 11:42:59 +01:00
parent 0260b160a6
commit 22a77ea842
3 changed files with 53 additions and 7 deletions

View File

@ -130,6 +130,7 @@ import static org.jooq.impl.Keywords.K_TRUE;
import static org.jooq.impl.Keywords.K_YEAR_TO_DAY;
import static org.jooq.impl.Keywords.K_YEAR_TO_FRACTION;
import static org.jooq.impl.Names.N_BYTEA;
import static org.jooq.impl.Names.N_PARSE_JSON;
import static org.jooq.impl.Names.N_ST_GEOMFROMTEXT;
import static org.jooq.impl.Names.N_ST_GEOMFROMWKB;
import static org.jooq.impl.R2DBC.isR2dbc;
@ -810,6 +811,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
case POSTGRES:
case YUGABYTEDB:
return true;
@ -941,6 +943,26 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
}
private final void sqlCast(BindingSQLContext<U> ctx, T converted, DataType<?> t, Integer length, Integer precision, Integer scale) throws SQLException {
switch (ctx.family()) {
default:
sqlCast0(ctx, converted, t, length, precision, scale);
break;
}
}
private final void sqlCast0(BindingSQLContext<U> ctx, T converted, DataType<?> t, Integer length, Integer precision, Integer scale) throws SQLException {
ctx.render().visit(K_CAST).sql('(');
sql(ctx, converted);
ctx.render().sql(' ').visit(K_AS).sql(' ')

View File

@ -191,6 +191,15 @@ final class FieldMapsForInsert extends AbstractQueryPart implements UNotYetImple
@ -207,19 +216,22 @@ final class FieldMapsForInsert extends AbstractQueryPart implements UNotYetImple
}
default: {
ctx.formatSeparator()
.start(INSERT_VALUES)
.visit(K_VALUES)
.sql(' ');
toSQL92Values(ctx);
ctx.end(INSERT_VALUES);
toSQLValues(ctx);
break;
}
}
}
}
private final void toSQLValues(Context<?> ctx) {
ctx.formatSeparator()
.start(INSERT_VALUES)
.visit(K_VALUES)
.sql(' ');
toSQL92Values(ctx);
ctx.end(INSERT_VALUES);
}
static final void toSQLInsertSelect(Context<?> ctx, Select<?> select) {
ctx.formatSeparator()
.start(INSERT_SELECT)
@ -326,6 +338,17 @@ final class FieldMapsForInsert extends AbstractQueryPart implements UNotYetImple

View File

@ -448,6 +448,7 @@ final class Names {
static final Name N_OCTET_LENGTH = systemName("octet_length");
static final Name N_OTRANSLATE = systemName("otranslate");
static final Name N_OVERLAY = systemName("overlay");
static final Name N_PARSE_JSON = systemName("parse_json");
static final Name N_PI = systemName("pi");
static final Name N_POSITION = systemName("position");
static final Name N_PRIOR = systemName("prior");