Merge branch 'main' of github.com:jOOQ/jOOQ into main
This commit is contained in:
commit
dd5cef3626
@ -2,6 +2,7 @@ package org.jooq.kotlin
|
||||
|
||||
import org.jetbrains.annotations.Blocking
|
||||
import org.jooq.*
|
||||
import org.jooq.SQLDialect.*
|
||||
import org.jooq.impl.DSL.*
|
||||
import java.util.stream.Collector
|
||||
|
||||
@ -290,10 +291,46 @@ operator fun <T> TableLike<*>.get(field: Field<T>) = this.field(field)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@Support
|
||||
operator fun <T> Field<Array<T>>.get(index: Int) = arrayGet(this, index)
|
||||
operator fun <T> Field<Array<T>?>.get(index: Int) = arrayGet(this, index)
|
||||
|
||||
@Support
|
||||
operator fun <T> Field<Array<T>>.get(index: Field<Int>) = arrayGet(this, index)
|
||||
operator fun <T> Field<Array<T>?>.get(index: Field<Int?>) = arrayGet(this, index)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Extensions to make Field<JSON> and Field<JSONB> aware of its being JSON
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@Support
|
||||
@JvmName("jsonGetElement")
|
||||
operator fun Field<JSON?>.get(index: Int) = jsonGetElement(this, index)
|
||||
|
||||
@Support
|
||||
@JvmName("jsonGetElement")
|
||||
operator fun Field<JSON?>.get(index: Field<Int?>) = jsonGetElement(this, index)
|
||||
|
||||
@Support
|
||||
@JvmName("jsonGetAttribute")
|
||||
operator fun Field<JSON?>.get(name: String) = jsonGetAttribute(this, name)
|
||||
|
||||
@Support
|
||||
@JvmName("jsonGetAttribute")
|
||||
operator fun Field<JSON?>.get(name: Field<String?>) = jsonGetAttribute(this, name)
|
||||
|
||||
@Support
|
||||
@JvmName("jsonbGetElement")
|
||||
operator fun Field<JSONB?>.get(index: Int) = jsonbGetElement(this, index)
|
||||
|
||||
@Support
|
||||
@JvmName("jsonbGetElement")
|
||||
operator fun Field<JSONB?>.get(index: Field<Int?>) = jsonbGetElement(this, index)
|
||||
|
||||
@Support
|
||||
@JvmName("jsonbGetAttribute")
|
||||
operator fun Field<JSONB?>.get(name: String) = jsonbGetAttribute(this, name)
|
||||
|
||||
@Support
|
||||
@JvmName("jsonbGetAttribute")
|
||||
operator fun Field<JSONB?>.get(name: Field<String?>) = jsonbGetAttribute(this, name)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Extensions to make Select<Record1<T>> a scalar subquery of type Field<T>
|
||||
|
||||
@ -11032,7 +11032,7 @@ public interface DSLContext extends Scope {
|
||||
* @see DSL#set(Name, Param)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ MYSQL, POSTGRES, YUGABYTEDB })
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
|
||||
RowCountQuery set(Name name, Param<?> value);
|
||||
|
||||
/**
|
||||
|
||||
@ -1259,7 +1259,7 @@ extends
|
||||
* Create a condition to check if this field contains JSON data.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MYSQL })
|
||||
@Support({ MARIADB, MYSQL })
|
||||
Condition isJson();
|
||||
|
||||
/**
|
||||
@ -1268,7 +1268,7 @@ extends
|
||||
* Create a condition to check if this field does not contain JSON data.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MYSQL })
|
||||
@Support({ MARIADB, MYSQL })
|
||||
Condition isNotJson();
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -106,14 +106,14 @@ public interface InsertOnDuplicateStep<R extends Record> extends InsertReturning
|
||||
* Add a <code>ON CONFLICT ON CONSTRAINT</code> clause to this INSERT statement.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, POSTGRES, YUGABYTEDB })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
|
||||
InsertOnConflictDoUpdateStep<R> onConflictOnConstraint(Constraint constraint);
|
||||
|
||||
/**
|
||||
* Add a <code>ON CONFLICT ON CONSTRAINT</code> clause to this INSERT statement.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, POSTGRES, YUGABYTEDB })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
|
||||
InsertOnConflictDoUpdateStep<R> onConflictOnConstraint(Name constraint);
|
||||
|
||||
/**
|
||||
|
||||
@ -143,7 +143,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>,
|
||||
* <code>ON CONFLICT ON CONSTRAINT</code> clause in this <code>INSERT</code>
|
||||
* statement.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, POSTGRES, YUGABYTEDB })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
|
||||
void onConflictOnConstraint(Name constraint);
|
||||
|
||||
/**
|
||||
@ -151,7 +151,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>,
|
||||
* <code>ON CONFLICT ON CONSTRAINT</code> clause in this <code>INSERT</code>
|
||||
* statement.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, POSTGRES, YUGABYTEDB })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
|
||||
void onConflictOnConstraint(Constraint constraint);
|
||||
|
||||
/**
|
||||
|
||||
@ -44,8 +44,11 @@ import org.jetbrains.annotations.*;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
@ -65,6 +68,6 @@ public interface JSONArrayAggReturningStep<T> extends AggregateFilterStep<T> {
|
||||
* function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ H2, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
@Support({ H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
AggregateFilterStep<T> returning(DataType<?> returning);
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.MARIADB;
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
|
||||
@ -1907,7 +1907,7 @@ public interface SelectJoinStep<R extends Record> extends SelectWhereStep<R> {
|
||||
* @see Table#straightJoin(TableLike)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ MYSQL })
|
||||
@Support({ MARIADB, MYSQL })
|
||||
SelectOnStep<R> straightJoin(TableLike<?> table);
|
||||
|
||||
/**
|
||||
@ -1922,7 +1922,7 @@ public interface SelectJoinStep<R extends Record> extends SelectWhereStep<R> {
|
||||
* @see Table#straightJoin(SQL)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ MYSQL })
|
||||
@Support({ MARIADB, MYSQL })
|
||||
@PlainSQL
|
||||
SelectOnStep<R> straightJoin(SQL sql);
|
||||
|
||||
@ -1938,7 +1938,7 @@ public interface SelectJoinStep<R extends Record> extends SelectWhereStep<R> {
|
||||
* @see Table#straightJoin(String)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ MYSQL })
|
||||
@Support({ MARIADB, MYSQL })
|
||||
@PlainSQL
|
||||
SelectOnStep<R> straightJoin(String sql);
|
||||
|
||||
@ -1955,7 +1955,7 @@ public interface SelectJoinStep<R extends Record> extends SelectWhereStep<R> {
|
||||
* @see Table#straightJoin(String, Object...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ MYSQL })
|
||||
@Support({ MARIADB, MYSQL })
|
||||
@PlainSQL
|
||||
SelectOnStep<R> straightJoin(String sql, Object... bindings);
|
||||
|
||||
@ -1972,7 +1972,7 @@ public interface SelectJoinStep<R extends Record> extends SelectWhereStep<R> {
|
||||
* @see Table#straightJoin(String, QueryPart...)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ MYSQL })
|
||||
@Support({ MARIADB, MYSQL })
|
||||
@PlainSQL
|
||||
SelectOnStep<R> straightJoin(String sql, QueryPart... parts);
|
||||
|
||||
@ -1983,6 +1983,6 @@ public interface SelectJoinStep<R extends Record> extends SelectWhereStep<R> {
|
||||
* @see Table#straightJoin(Name)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ MYSQL })
|
||||
@Support({ MARIADB, MYSQL })
|
||||
SelectOnStep<R> straightJoin(Name name);
|
||||
}
|
||||
|
||||
@ -292,10 +292,10 @@ implements
|
||||
|
||||
|
||||
else
|
||||
ctx.visit(wrap(args).map((arg, i) -> applyFilter(arg, i) ? DSL.when(filter, arg == ASTERISK ? one() : arg) : arg).map(fun));
|
||||
ctx.visit(wrap(args).map((arg, i) -> applyFilter(ctx, arg, i) ? DSL.when(filter, arg == ASTERISK ? one() : arg) : arg).map(fun));
|
||||
}
|
||||
|
||||
boolean applyFilter(Field<?> arg, int i) {
|
||||
boolean applyFilter(Context<?> ctx, Field<?> arg, int i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -64,15 +64,6 @@ abstract class AbstractCondition extends AbstractField<Boolean> implements Condi
|
||||
super(DSL.name("condition"), SQLDataType.BOOLEAN);
|
||||
}
|
||||
|
||||
/**
|
||||
* [#10179] Subclasses may override this method to indicate that the
|
||||
* condition may produce <code>TRUE</code>, <code>FALSE</code>, or
|
||||
* <code>NULL</code>.
|
||||
*/
|
||||
boolean isNullable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSES;
|
||||
|
||||
@ -121,6 +121,15 @@ implements
|
||||
// XXX: API (not implemented)
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* [#10179] [#14665] Subclasses may override this method to indicate that
|
||||
* the condition may produce <code>TRUE</code>, <code>FALSE</code>, or
|
||||
* <code>NULL</code>.
|
||||
*/
|
||||
boolean isNullable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void accept(Context<?> ctx);
|
||||
|
||||
|
||||
@ -10013,7 +10013,7 @@ public class DSL {
|
||||
* @see DSLContext#set(Name, Param)
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ MYSQL, POSTGRES, YUGABYTEDB })
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
|
||||
public static org.jooq.RowCountQuery set(Name name, Param<?> value) {
|
||||
return dsl().set(name, value);
|
||||
}
|
||||
@ -23785,7 +23785,7 @@ public class DSL {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the <code>REGEXP_REPLACE_ALL</code> function.
|
||||
* Get the <code>REGEXP_REPLACE_FIRST</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MYSQL, POSTGRES, YUGABYTEDB })
|
||||
@ -23794,7 +23794,7 @@ public class DSL {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the <code>REGEXP_REPLACE_ALL</code> function.
|
||||
* Get the <code>REGEXP_REPLACE_FIRST</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MYSQL, POSTGRES, YUGABYTEDB })
|
||||
|
||||
@ -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;
|
||||
@ -800,16 +801,12 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
|
||||
// [#7242] [#13252] Other vendor specific types also need a lot of casting
|
||||
if (dataType.isJSON()
|
||||
|| dataType.isXML()
|
||||
|
||||
|
||||
|
||||
) {
|
||||
if (dataType.isJSON() || dataType.isXML()) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
case POSTGRES:
|
||||
case YUGABYTEDB:
|
||||
return true;
|
||||
@ -820,6 +817,20 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -941,6 +952,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(' ')
|
||||
@ -5458,7 +5489,13 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
|
||||
|
||||
static final class DefaultJSONBinding<U> extends InternalBinding<JSON, U> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static final class DefaultJSONBinding<U> extends InternalBinding<org.jooq.JSON, U> {
|
||||
|
||||
DefaultJSONBinding(DataType<JSON> dataType, Converter<JSON, U> converter) {
|
||||
super(dataType, converter);
|
||||
|
||||
@ -85,15 +85,15 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
private static final Clause[] CLAUSES_EXISTS = { Clause.CONDITION, Clause.CONDITION_EXISTS };
|
||||
|
||||
@Override
|
||||
final boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static final Clause[] CLAUSES_EXISTS = { Clause.CONDITION, Clause.CONDITION_EXISTS };
|
||||
|
||||
@Override
|
||||
final boolean parenthesised(Context<?> ctx) {
|
||||
return true;
|
||||
|
||||
@ -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)
|
||||
@ -329,6 +341,20 @@ final class FieldMapsForInsert extends AbstractQueryPart implements UNotYetImple
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -88,6 +88,11 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
final boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static final Set<SQLDialect> EMULATE_DISTINCT_PREDICATE = SQLDialect.supportedUntil(CUBRID, DERBY);
|
||||
@ -97,11 +102,6 @@ implements
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
final boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
|
||||
|
||||
@ -85,6 +85,27 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
final boolean parenthesised(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
@ -94,6 +115,7 @@ implements
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
ctx.visit(function(N_JSON_VALID, BOOLEAN, field));
|
||||
break;
|
||||
@ -106,6 +128,11 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
ctx.visit(field).sql(' ').visit(K_IS_JSON);
|
||||
break;
|
||||
|
||||
@ -88,13 +88,13 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
final boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
|
||||
|
||||
@ -94,6 +94,7 @@ implements
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
ctx.visit(condition(function(N_JSON_VALID, BOOLEAN, field)).not());
|
||||
break;
|
||||
@ -106,6 +107,11 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
ctx.visit(field).sql(' ').visit(K_IS_NOT_JSON);
|
||||
break;
|
||||
|
||||
@ -85,15 +85,15 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
private static final Clause[] CLAUSES = { Clause.CONDITION, Clause.CONDITION_IS_NOT_NULL };
|
||||
|
||||
@Override
|
||||
final boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static final Clause[] CLAUSES = { Clause.CONDITION, Clause.CONDITION_IS_NOT_NULL };
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
|
||||
|
||||
@ -85,15 +85,15 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
private static final Clause[] CLAUSES = { Clause.CONDITION, Clause.CONDITION_IS_NULL };
|
||||
|
||||
@Override
|
||||
final boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static final Clause[] CLAUSES = { Clause.CONDITION, Clause.CONDITION_IS_NULL };
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
|
||||
|
||||
@ -134,6 +134,11 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
final boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@ -193,6 +198,10 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -137,6 +137,11 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -92,6 +92,33 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
final boolean parenthesised(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
@ -123,6 +150,10 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -92,6 +92,33 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
final boolean parenthesised(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
@ -118,6 +145,10 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -91,6 +91,31 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
final boolean parenthesised(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
case POSTGRES:
|
||||
case YUGABYTEDB:
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case SQLITE:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
@ -119,6 +144,10 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case SQLITE:
|
||||
ctx.visit(DSL.field(select(jsonbArrayAgg(DSL.field(name("key")))).from("json_each({0})", field)));
|
||||
break;
|
||||
|
||||
@ -62,7 +62,9 @@ import static org.jooq.impl.Names.N_JSON_EXTRACT;
|
||||
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_PARSE_JSON;
|
||||
import static org.jooq.impl.Names.N_RAWTOHEX;
|
||||
import static org.jooq.impl.Names.N_TO_VARIANT;
|
||||
import static org.jooq.impl.SQLDataType.BIT;
|
||||
import static org.jooq.impl.SQLDataType.BOOLEAN;
|
||||
import static org.jooq.impl.SQLDataType.JSON;
|
||||
@ -78,9 +80,11 @@ import java.util.function.Function;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.JSON;
|
||||
import org.jooq.JSONEntry;
|
||||
import org.jooq.JSONEntryValueStep;
|
||||
import org.jooq.Param;
|
||||
// ...
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record1;
|
||||
// ...
|
||||
@ -292,6 +296,21 @@ final class JSONEntryImpl<T> extends AbstractQueryPart implements JSONEntry<T>,
|
||||
return field;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Field<String> booleanCase(Field<?> field) {
|
||||
return case_((Field<Boolean>) field).when(inline(true), inline("true")).when(inline(false), inline("false"));
|
||||
|
||||
@ -92,6 +92,33 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
final boolean parenthesised(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
@ -123,6 +150,10 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -92,6 +92,33 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
final boolean parenthesised(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
@ -118,6 +145,10 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -103,6 +103,9 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case SQLITE:
|
||||
return false;
|
||||
|
||||
@ -135,6 +138,10 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case SQLITE:
|
||||
ctx.visit(DSL.field(select(jsonArrayAgg(DSL.field(name("key")))).from("json_each({0})", field)));
|
||||
break;
|
||||
|
||||
@ -134,6 +134,11 @@ implements
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
final boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -48,6 +48,7 @@ import static org.jooq.impl.Names.N_JSONB_OBJECT_AGG;
|
||||
import static org.jooq.impl.Names.N_JSON_GROUP_OBJECT;
|
||||
import static org.jooq.impl.Names.N_JSON_OBJECTAGG;
|
||||
import static org.jooq.impl.Names.N_JSON_OBJECT_AGG;
|
||||
import static org.jooq.impl.Names.N_OBJECT_AGG;
|
||||
import static org.jooq.impl.QOM.JSONOnNull.ABSENT_ON_NULL;
|
||||
import static org.jooq.impl.QOM.JSONOnNull.NULL_ON_NULL;
|
||||
import static org.jooq.impl.SQLDataType.BLOB;
|
||||
@ -105,6 +106,10 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case POSTGRES:
|
||||
case YUGABYTEDB:
|
||||
acceptPostgres(ctx);
|
||||
@ -162,6 +167,33 @@ implements
|
||||
acceptOverClause(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private final void acceptGroupConcat(Context<?> ctx) {
|
||||
ctx.sql('(').visit(groupConcatEmulation(ctx)).sql(')');
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ final class ListAgg extends AbstractAggregateFunction<String> implements UNotYet
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean applyFilter(Field<?> arg, int i) {
|
||||
boolean applyFilter(Context<?> ctx, Field<?> arg, int i) {
|
||||
return i == 0;
|
||||
}
|
||||
|
||||
|
||||
@ -83,6 +83,7 @@ final class Names {
|
||||
static final Name N_BYTE_LENGTH = systemName("byte_length");
|
||||
static final Name N_CAST = systemName("cast");
|
||||
static final Name N_CHARINDEX = systemName("charindex");
|
||||
static final Name N_CHECK_JSON = systemName("check_json");
|
||||
static final Name N_CHOOSE = systemName("choose");
|
||||
static final Name N_COLLECT = systemName("collect");
|
||||
static final Name N_CONCAT = systemName("concat");
|
||||
@ -170,7 +171,6 @@ final class Names {
|
||||
static final Name N_JSON_TRANSFORM = systemName("json_transform");
|
||||
static final Name N_JSON_TYPE = systemName("json_type");
|
||||
static final Name N_JSON_UNQUOTE = systemName("json_unquote");
|
||||
static final Name N_JSON_VALID = systemName("json_valid");
|
||||
static final Name N_JSON_VALUE = systemName("json_value");
|
||||
static final Name N_LAG = systemName("lag");
|
||||
static final Name N_LAST_VALUE = systemName("last_value");
|
||||
@ -200,6 +200,7 @@ final class Names {
|
||||
static final Name N_NTILE = systemName("ntile");
|
||||
static final Name N_NULL = systemName("null");
|
||||
static final Name N_NVL2 = systemName("nvl2");
|
||||
static final Name N_OBJECT_AGG = systemName("object_agg");
|
||||
static final Name N_OBJECT_CONSTRUCT = systemName("object_construct");
|
||||
static final Name N_OBJECT_CONSTRUCT_KEEP_NULL = systemName("object_construct_keep_null");
|
||||
static final Name N_OFFSET = systemName("offset");
|
||||
@ -207,6 +208,7 @@ final class Names {
|
||||
static final Name N_OPENXML = systemName("openxml");
|
||||
static final Name N_ORDINAL = systemName("ordinal");
|
||||
static final Name N_OREPLACE = systemName("oreplace");
|
||||
static final Name N_PARSE_JSON = systemName("parse_json");
|
||||
static final Name N_PERCENTILE_CONT = systemName("percentile_cont");
|
||||
static final Name N_PERCENTILE_DISC = systemName("percentile_disc");
|
||||
static final Name N_PERCENT_RANK = systemName("percent_rank");
|
||||
@ -274,6 +276,7 @@ final class Names {
|
||||
static final Name N_TIMESTAMP_SUB = systemName("timestamp_sub");
|
||||
static final Name N_TO_CLOB = systemName("to_clob");
|
||||
static final Name N_TO_NUMBER = systemName("to_number");
|
||||
static final Name N_TO_VARIANT = systemName("to_variant");
|
||||
static final Name N_TRUNCATE = systemName("truncate");
|
||||
static final Name N_TRUNCNUM = systemName("truncnum");
|
||||
static final Name N_UNNEST = systemName("unnest");
|
||||
@ -392,6 +395,7 @@ final class Names {
|
||||
static final Name N_GENERATE_UUID = systemName("generate_uuid");
|
||||
static final Name N_GENGUID = systemName("genguid");
|
||||
static final Name N_GEN_RANDOM_UUID = systemName("gen_random_uuid");
|
||||
static final Name N_GET = systemName("get");
|
||||
static final Name N_GETBIT = systemName("getbit");
|
||||
static final Name N_GET_BIT = systemName("get_bit");
|
||||
static final Name N_GOTO = systemName("goto");
|
||||
@ -420,6 +424,7 @@ final class Names {
|
||||
static final Name N_JSON_REMOVE = systemName("json_remove");
|
||||
static final Name N_JSON_REPLACE = systemName("json_replace");
|
||||
static final Name N_JSON_SET = systemName("json_set");
|
||||
static final Name N_JSON_VALID = systemName("json_valid");
|
||||
static final Name N_LCASE = systemName("lcase");
|
||||
static final Name N_LEFT = systemName("left");
|
||||
static final Name N_LEN = systemName("len");
|
||||
@ -443,6 +448,7 @@ final class Names {
|
||||
static final Name N_NEWID = systemName("newid");
|
||||
static final Name N_NULLIF = systemName("nullif");
|
||||
static final Name N_NVL = systemName("nvl");
|
||||
static final Name N_OBJECT_KEYS = systemName("object_keys");
|
||||
static final Name N_OCTET_LENGTH = systemName("octet_length");
|
||||
static final Name N_OTRANSLATE = systemName("otranslate");
|
||||
static final Name N_OVERLAY = systemName("overlay");
|
||||
|
||||
@ -71,11 +71,6 @@ implements
|
||||
static final NullCondition INSTANCE = new NullCondition();
|
||||
static final Set<SQLDialect> NO_SUPPORT_UNTYPED_NULL = SQLDialect.supportedBy(DERBY, HSQLDB);
|
||||
|
||||
@Override
|
||||
final boolean isNullable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
final boolean parenthesised(Context<?> ctx) {
|
||||
return !NO_SUPPORT_UNTYPED_NULL.contains(ctx.dialect())
|
||||
|
||||
@ -8876,6 +8876,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
return octetLength((Field) parseFieldParenthesised());
|
||||
else if ((field = parseFieldObjectConstructIf()) != null)
|
||||
return field;
|
||||
else if (parseFunctionNameIf("OBJECT_KEYS"))
|
||||
return parseFunctionArgs1(DSL::jsonKeys);
|
||||
|
||||
break;
|
||||
|
||||
@ -10053,9 +10055,9 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
|
||||
private final AggregateFilterStep<?> parseJSONObjectAggFunctionIf() {
|
||||
boolean jsonb = false;
|
||||
AggregateFilterStep<?> result;
|
||||
|
||||
if (parseFunctionNameIf("JSON_OBJECTAGG", "JSON_OBJECT_AGG", "JSON_GROUP_OBJECT") || (jsonb = parseFunctionNameIf("JSONB_OBJECT_AGG"))) {
|
||||
AggregateFilterStep<?> result;
|
||||
JSONObjectAggNullStep<?> s1;
|
||||
JSONObjectAggReturningStep<?> s2;
|
||||
JSONOnNull onNull;
|
||||
@ -10073,6 +10075,14 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
|
||||
parse(')');
|
||||
return result;
|
||||
}
|
||||
else if (parseFunctionNameIf("OBJECT_AGG") && requireProEdition()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@ -3799,6 +3799,11 @@ final class Tools {
|
||||
return field instanceof Param;
|
||||
}
|
||||
|
||||
static final boolean isParamOrCastParam(Field<?> field) {
|
||||
return field instanceof Param
|
||||
|| field instanceof Cast && isParamOrCastParam(((Cast<?>) field).$field());
|
||||
}
|
||||
|
||||
static final boolean isVal(Field<?> field) {
|
||||
return field instanceof Val
|
||||
|| field instanceof ConvertedVal && ((ConvertedVal<?>) field).delegate instanceof Val;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user