[jOOQ/jOOQ#14827] Add support for the JSON_KEY_EXISTS() function

This commit is contained in:
Lukas Eder 2024-05-17 15:01:16 +02:00
parent cb18d58ba7
commit 545c218503
6 changed files with 660 additions and 35 deletions

View File

@ -23915,6 +23915,118 @@ public class DSL {
return new JSONBArrayLength(field);
}
/**
* The <code>JSON_KEY_EXISTS</code> function.
* <p>
* Check if a key exists in a JSON object
*
* @param json The JSON object
* @param key The key in the JSON object
*/
@NotNull
@Support({ CLICKHOUSE, MARIADB, MYSQL, POSTGRES, SQLITE, TRINO, YUGABYTEDB })
public static Condition jsonKeyExists(JSON json, @Stringly.Param String key) {
return new JSONKeyExists(Tools.field(json), Tools.field(key));
}
/**
* The <code>JSON_KEY_EXISTS</code> function.
* <p>
* Check if a key exists in a JSON object
*
* @param json The JSON object
* @param key The key in the JSON object
*/
@NotNull
@Support({ CLICKHOUSE, MARIADB, MYSQL, POSTGRES, SQLITE, TRINO, YUGABYTEDB })
public static Condition jsonKeyExists(JSON json, Field<String> key) {
return new JSONKeyExists(Tools.field(json), key);
}
/**
* The <code>JSON_KEY_EXISTS</code> function.
* <p>
* Check if a key exists in a JSON object
*
* @param json The JSON object
* @param key The key in the JSON object
*/
@NotNull
@Support({ CLICKHOUSE, MARIADB, MYSQL, POSTGRES, SQLITE, TRINO, YUGABYTEDB })
public static Condition jsonKeyExists(Field<JSON> json, @Stringly.Param String key) {
return new JSONKeyExists(json, Tools.field(key));
}
/**
* The <code>JSON_KEY_EXISTS</code> function.
* <p>
* Check if a key exists in a JSON object
*
* @param json The JSON object
* @param key The key in the JSON object
*/
@NotNull
@Support({ CLICKHOUSE, MARIADB, MYSQL, POSTGRES, SQLITE, TRINO, YUGABYTEDB })
public static Condition jsonKeyExists(Field<JSON> json, Field<String> key) {
return new JSONKeyExists(json, key);
}
/**
* The <code>JSONB_KEY_EXISTS</code> function.
* <p>
* Check if a key exists in a JSONB object
*
* @param json The JSONB object
* @param key The key in the JSONB object
*/
@NotNull
@Support({ CLICKHOUSE, MARIADB, MYSQL, POSTGRES, SQLITE, TRINO, YUGABYTEDB })
public static Condition jsonbKeyExists(JSONB json, @Stringly.Param String key) {
return new JSONBKeyExists(Tools.field(json), Tools.field(key));
}
/**
* The <code>JSONB_KEY_EXISTS</code> function.
* <p>
* Check if a key exists in a JSONB object
*
* @param json The JSONB object
* @param key The key in the JSONB object
*/
@NotNull
@Support({ CLICKHOUSE, MARIADB, MYSQL, POSTGRES, SQLITE, TRINO, YUGABYTEDB })
public static Condition jsonbKeyExists(JSONB json, Field<String> key) {
return new JSONBKeyExists(Tools.field(json), key);
}
/**
* The <code>JSONB_KEY_EXISTS</code> function.
* <p>
* Check if a key exists in a JSONB object
*
* @param json The JSONB object
* @param key The key in the JSONB object
*/
@NotNull
@Support({ CLICKHOUSE, MARIADB, MYSQL, POSTGRES, SQLITE, TRINO, YUGABYTEDB })
public static Condition jsonbKeyExists(Field<JSONB> json, @Stringly.Param String key) {
return new JSONBKeyExists(json, Tools.field(key));
}
/**
* The <code>JSONB_KEY_EXISTS</code> function.
* <p>
* Check if a key exists in a JSONB object
*
* @param json The JSONB object
* @param key The key in the JSONB object
*/
@NotNull
@Support({ CLICKHOUSE, MARIADB, MYSQL, POSTGRES, SQLITE, TRINO, YUGABYTEDB })
public static Condition jsonbKeyExists(Field<JSONB> json, Field<String> key) {
return new JSONBKeyExists(json, key);
}
/**
* The <code>JSON_KEYS</code> function.
* <p>

View File

@ -0,0 +1,209 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: https://www.jooq.org/legal/licensing
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.*;
import static org.jooq.impl.Internal.*;
import static org.jooq.impl.Keywords.*;
import static org.jooq.impl.Names.*;
import static org.jooq.impl.SQLDataType.*;
import static org.jooq.impl.Tools.*;
import static org.jooq.impl.Tools.BooleanDataKey.*;
import static org.jooq.impl.Tools.ExtendedDataKey.*;
import static org.jooq.impl.Tools.SimpleDataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Function1;
import org.jooq.Record;
import org.jooq.conf.ParamType;
import org.jooq.tools.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
/**
* The <code>JSONB KEY EXISTS</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
final class JSONBKeyExists
extends
AbstractCondition
implements
QOM.JSONBKeyExists
{
final Field<JSONB> json;
final Field<String> key;
JSONBKeyExists(
Field<JSONB> json,
Field<String> key
) {
this.json = nullSafeNotNull(json, JSONB);
this.key = nullSafeNotNull(key, VARCHAR);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
switch (ctx.family()) {
case CLICKHOUSE:
case MARIADB:
case MYSQL:
case SQLITE:
case TRINO:
return false;
case POSTGRES:
case YUGABYTEDB:
return false;
default:
return true;
}
}
@Override
public final void accept(Context<?> ctx) {
switch (ctx.family()) {
case CLICKHOUSE:
case MARIADB:
case MYSQL:
case SQLITE:
case TRINO:
ctx.visit(jsonbGetAttribute(json, key).isNotNull());
break;
case POSTGRES:
case YUGABYTEDB: {
ctx.sql('(').visit(json).sql(" ?? ").visit(key).sql(')');
break;
}
default:
ctx.visit(function(N_JSONB_KEY_EXISTS, BOOLEAN, json, key));
break;
}
}
// -------------------------------------------------------------------------
// XXX: Query Object Model
// -------------------------------------------------------------------------
@Override
public final Field<JSONB> $arg1() {
return json;
}
@Override
public final Field<String> $arg2() {
return key;
}
@Override
public final QOM.JSONBKeyExists $arg1(Field<JSONB> newValue) {
return $constructor().apply(newValue, $arg2());
}
@Override
public final QOM.JSONBKeyExists $arg2(Field<String> newValue) {
return $constructor().apply($arg1(), newValue);
}
@Override
public final Function2<? super Field<JSONB>, ? super Field<String>, ? extends QOM.JSONBKeyExists> $constructor() {
return (a1, a2) -> new JSONBKeyExists(a1, a2);
}
// -------------------------------------------------------------------------
// XXX: The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof QOM.JSONBKeyExists o) {
return
StringUtils.equals($json(), o.$json()) &&
StringUtils.equals($key(), o.$key())
;
}
else
return super.equals(that);
}
}

View File

@ -0,0 +1,219 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: https://www.jooq.org/legal/licensing
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.*;
import static org.jooq.impl.Internal.*;
import static org.jooq.impl.Keywords.*;
import static org.jooq.impl.Names.*;
import static org.jooq.impl.SQLDataType.*;
import static org.jooq.impl.Tools.*;
import static org.jooq.impl.Tools.BooleanDataKey.*;
import static org.jooq.impl.Tools.ExtendedDataKey.*;
import static org.jooq.impl.Tools.SimpleDataKey.*;
import static org.jooq.SQLDialect.*;
import org.jooq.*;
import org.jooq.Function1;
import org.jooq.Record;
import org.jooq.conf.ParamType;
import org.jooq.tools.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
/**
* The <code>JSON KEY EXISTS</code> statement.
*/
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
final class JSONKeyExists
extends
AbstractCondition
implements
QOM.JSONKeyExists
{
final Field<JSON> json;
final Field<String> key;
JSONKeyExists(
Field<JSON> json,
Field<String> key
) {
this.json = nullSafeNotNull(json, JSON);
this.key = nullSafeNotNull(key, VARCHAR);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean parenthesised(Context<?> ctx) {
switch (ctx.family()) {
case CLICKHOUSE:
case MARIADB:
case MYSQL:
case SQLITE:
case TRINO:
return false;
case POSTGRES:
case YUGABYTEDB:
return false;
default:
return true;
}
}
@Override
public final void accept(Context<?> ctx) {
switch (ctx.family()) {
case CLICKHOUSE:
case MARIADB:
case MYSQL:
case SQLITE:
case TRINO:
ctx.visit(jsonGetAttribute(json, key).isNotNull());
break;
case POSTGRES:
case YUGABYTEDB: {
ctx.sql('(').visit(json.cast(JSONB)).sql(" ?? ").visit(key).sql(')');
break;
}
default:
ctx.visit(function(N_JSON_KEY_EXISTS, BOOLEAN, json, key));
break;
}
}
// -------------------------------------------------------------------------
// XXX: Query Object Model
// -------------------------------------------------------------------------
@Override
public final Field<JSON> $arg1() {
return json;
}
@Override
public final Field<String> $arg2() {
return key;
}
@Override
public final QOM.JSONKeyExists $arg1(Field<JSON> newValue) {
return $constructor().apply(newValue, $arg2());
}
@Override
public final QOM.JSONKeyExists $arg2(Field<String> newValue) {
return $constructor().apply($arg1(), newValue);
}
@Override
public final Function2<? super Field<JSON>, ? super Field<String>, ? extends QOM.JSONKeyExists> $constructor() {
return (a1, a2) -> new JSONKeyExists(a1, a2);
}
// -------------------------------------------------------------------------
// XXX: The Object API
// -------------------------------------------------------------------------
@Override
public boolean equals(Object that) {
if (that instanceof QOM.JSONKeyExists o) {
return
StringUtils.equals($json(), o.$json()) &&
StringUtils.equals($key(), o.$key())
;
}
else
return super.equals(that);
}
}

View File

@ -481,6 +481,7 @@ final class Names {
static final Name N_JSONB_GET_ELEMENT_AS_TEXT = systemName("jsonb_get_element_as_text");
static final Name N_JSONB_INSERT = systemName("jsonb_insert");
static final Name N_JSONB_KEYS = systemName("jsonb_keys");
static final Name N_JSONB_KEY_EXISTS = systemName("jsonb_key_exists");
static final Name N_JSONB_OBJECT = systemName("jsonb_object");
static final Name N_JSONB_REMOVE = systemName("jsonb_remove");
static final Name N_JSONB_REPLACE = systemName("jsonb_replace");
@ -497,6 +498,7 @@ final class Names {
static final Name N_JSON_GET_ELEMENT_AS_TEXT = systemName("json_get_element_as_text");
static final Name N_JSON_INSERT = systemName("json_insert");
static final Name N_JSON_KEYS = systemName("json_keys");
static final Name N_JSON_KEY_EXISTS = systemName("json_key_exists");
static final Name N_JSON_LENGTH = systemName("json_length");
static final Name N_JSON_MODIFY = systemName("json_modify");
static final Name N_JSON_OBJECT = systemName("json_object");

View File

@ -219,6 +219,7 @@ import static org.jooq.impl.DSL.jsonGetAttribute;
import static org.jooq.impl.DSL.jsonGetAttributeAsText;
import static org.jooq.impl.DSL.jsonGetElement;
import static org.jooq.impl.DSL.jsonGetElementAsText;
import static org.jooq.impl.DSL.jsonKeyExists;
import static org.jooq.impl.DSL.jsonObject;
import static org.jooq.impl.DSL.jsonObjectAgg;
import static org.jooq.impl.DSL.jsonTable;
@ -230,6 +231,7 @@ import static org.jooq.impl.DSL.jsonbGetAttribute;
import static org.jooq.impl.DSL.jsonbGetAttributeAsText;
import static org.jooq.impl.DSL.jsonbGetElement;
import static org.jooq.impl.DSL.jsonbGetElementAsText;
import static org.jooq.impl.DSL.jsonbKeyExists;
import static org.jooq.impl.DSL.jsonbObject;
import static org.jooq.impl.DSL.jsonbObjectAgg;
import static org.jooq.impl.DSL.key;
@ -8164,7 +8166,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
}
private final FieldOrRow parseCollated() {
FieldOrRow r = parseNumericOp();
FieldOrRow r = parseOp();
if (r instanceof Field) {
if (parseKeywordIf("COLLATE"))
@ -8213,7 +8215,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
private final Field<?> parseFieldNumericOpParenthesised() {
parse('(');
Field<?> r = toField(parseNumericOp());
Field<?> r = toField(parseOp());
parse(')');
return r;
@ -8318,7 +8320,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
// Any numeric operator of low precedence
// See https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-PRECEDENCE
private final FieldOrRow parseNumericOp() {
private final FieldOrRow parseOp() {
FieldOrRow l = parseSum();
if (l instanceof Field)
@ -8363,6 +8365,11 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else
l = jsonbGetAttribute((Field) l, r);
}
else if (parseIf("??") || parseIf("?"))
if (((Field) l).getType() == JSON.class)
return jsonKeyExists((Field) l, (Field) parseSum());
else
return jsonbKeyExists((Field) l, (Field) parseSum());
else
break;
@ -8749,7 +8756,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else if (parseFunctionNameIf("ATANH"))
return atanh((Field) parseFieldNumericOpParenthesised());
else if (parseFunctionNameIf("ATN2", "ATAN2"))
return parseFunctionArgs2(() -> toField(parseNumericOp()), DSL::atan2);
return parseFunctionArgs2(() -> toField(parseOp()), DSL::atan2);
else if (parseFunctionNameIf("ASCII_CHAR"))
return chr((Field) parseFieldParenthesised());
@ -8816,9 +8823,9 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else if (parseFunctionNameIf("BITCOUNT", "BIT_COUNT"))
return bitCount((Field) parseFieldNumericOpParenthesised());
else if (parseKeywordIf("BIT_LSHIFT"))
return parseFunctionArgs2(() -> toField(parseNumericOp()), (f1, f2) -> shl(f1, f2));
return parseFunctionArgs2(() -> toField(parseOp()), (f1, f2) -> shl(f1, f2));
else if (parseKeywordIf("BIT_RSHIFT"))
return parseFunctionArgs2(() -> toField(parseNumericOp()), (f1, f2) -> shr(f1, f2));
return parseFunctionArgs2(() -> toField(parseOp()), (f1, f2) -> shr(f1, f2));
else if (parseFunctionNameIf("BYTE_LENGTH"))
return octetLength((Field) parseFieldParenthesised());
else if ((field = parseFieldBitwiseFunctionIf()) != null)
@ -9103,6 +9110,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
return parseFunctionArgs1(DSL::jsonArrayLength);
else if (parseFunctionNameIf("JSON_KEYS", "JSONExtractKeys"))
return parseFunctionArgs1(DSL::jsonKeys);
else if (parseFunctionNameIf("JSON_KEY_EXISTS"))
return parseFunctionArgs2(DSL::jsonKeyExists);
else if (parseFunctionNameIf("JSON_INSERT"))
return parseFunctionArgs3(DSL::jsonInsert);
else if (parseFunctionNameIf("JSON_REMOVE"))
@ -9117,6 +9126,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
return parseFunctionArgs1(DSL::jsonbArrayLength);
else if (parseFunctionNameIf("JSONB_KEYS"))
return parseFunctionArgs1(DSL::jsonbKeys);
else if (parseFunctionNameIf("JSONB_KEY_EXISTS"))
return parseFunctionArgs2(DSL::jsonbKeyExists);
else if (parseFunctionNameIf("JSONB_INSERT"))
return parseFunctionArgs3(DSL::jsonbInsert);
else if (parseFunctionNameIf("JSONB_REMOVE"))
@ -9155,7 +9166,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
}
else if (parseKeywordIf("LSHIFT", "LEFT_SHIFT"))
return parseFunctionArgs2(() -> toField(parseNumericOp()), (f1, f2) -> shl(f1, f2));
return parseFunctionArgs2(() -> toField(parseOp()), (f1, f2) -> shl(f1, f2));
else if ((field = parseFieldLeastIf()) != null)
return field;
else if ((field = parseFieldLeadLagIf()) != null)
@ -9266,7 +9277,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else if ((field = parseFieldPercentRankIf()) != null)
return field;
else if (parseFunctionNameIf("POWER", "POW"))
return parseFunctionArgs2(() -> toField(parseNumericOp()), DSL::power);
return parseFunctionArgs2(() -> toField(parseOp()), DSL::power);
else if (parseFunctionNameIf("PI") && parseEmptyParens())
return pi();
@ -9331,7 +9342,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else if (parseFunctionNameIf("RATIO_TO_REPORT"))
return parseFunctionArgs1(f -> parseWindowFunction(null, null, ratioToReport(f)));
else if (parseKeywordIf("RSHIFT", "RIGHT_SHIFT"))
return parseFunctionArgs2(() -> toField(parseNumericOp()), (f1, f2) -> shr(f1, f2));
return parseFunctionArgs2(() -> toField(parseOp()), (f1, f2) -> shr(f1, f2));
else if (parseFunctionNameIf("ROOT"))
return parseFunctionArgs2(DSL::sqrt, DSL::root);
else if (parseFunctionNameIf("ROW"))
@ -9381,9 +9392,9 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
else if (parseFunctionNameIf("SIN"))
return sin((Field) parseFieldNumericOpParenthesised());
else if (parseKeywordIf("SHL", "SHIFTLEFT"))
return parseFunctionArgs2(() -> toField(parseNumericOp()), (f1, f2) -> shl(f1, f2));
return parseFunctionArgs2(() -> toField(parseOp()), (f1, f2) -> shl(f1, f2));
else if (parseKeywordIf("SHR", "SHIFTRIGHT"))
return parseFunctionArgs2(() -> toField(parseNumericOp()), (f1, f2) -> shr(f1, f2));
return parseFunctionArgs2(() -> toField(parseOp()), (f1, f2) -> shr(f1, f2));
else if ((field = parseFieldSysConnectByPathIf()) != null)
return field;
else if ((field = parseFieldCastIf()) != null)
@ -9900,13 +9911,13 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
parse('(');
if (parseKeywordIf("DISTINCT", "ALL"))
agg = true;
Field<?> x = toField(parseNumericOp());
Field<?> x = toField(parseOp());
if (agg && parse(')') || parseIf(')'))
return parseAggregateFunctionIf(false, bitAndAgg((Field) x));
parse(',');
Field<?> y = toField(parseNumericOp());
Field<?> y = toField(parseOp());
parse(')');
return bitAnd((Field) x, (Field) y);
@ -9921,13 +9932,13 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
parse('(');
if (parseKeywordIf("DISTINCT", "ALL"))
agg = true;
Field<?> x = toField(parseNumericOp());
Field<?> x = toField(parseOp());
if (agg && parse(')') || parseIf(')'))
return parseAggregateFunctionIf(false, bitNandAgg((Field) x));
parse(',');
Field<?> y = toField(parseNumericOp());
Field<?> y = toField(parseOp());
parse(')');
return bitNand((Field) x, (Field) y);
@ -9944,13 +9955,13 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
parse('(');
if (parseKeywordIf("DISTINCT", "ALL"))
agg = true;
Field<?> x = toField(parseNumericOp());
Field<?> x = toField(parseOp());
if (agg && parse(')') || parseIf(')'))
return parseAggregateFunctionIf(false, bitOrAgg((Field) x));
parse(',');
Field<?> y = toField(parseNumericOp());
Field<?> y = toField(parseOp());
parse(')');
return bitOr((Field) x, (Field) y);
@ -9965,13 +9976,13 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
parse('(');
if (parseKeywordIf("DISTINCT", "ALL"))
agg = true;
Field<?> x = toField(parseNumericOp());
Field<?> x = toField(parseOp());
if (agg && parse(')') || parseIf(')'))
return parseAggregateFunctionIf(false, bitNorAgg((Field) x));
parse(',');
Field<?> y = toField(parseNumericOp());
Field<?> y = toField(parseOp());
parse(')');
return bitNor((Field) x, (Field) y);
@ -9985,13 +9996,13 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
(agg = parseKeywordIf("BIN_XOR_AGG")) ||
(agg = parseKeywordIf("groupBitXor"))) {
parse('(');
Field<?> x = toField(parseNumericOp());
Field<?> x = toField(parseOp());
if (agg && parse(')') || parseIf(')'))
return parseAggregateFunctionIf(false, bitXorAgg((Field) x));
parse(',');
Field<?> y = toField(parseNumericOp());
Field<?> y = toField(parseOp());
parse(')');
return bitXor((Field) x, (Field) y);
@ -10004,38 +10015,38 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
(agg = parseKeywordIf("BIN_XNOR_AGG")) ||
(agg = parseKeywordIf("groupBitXnor"))) {
parse('(');
Field<?> x = toField(parseNumericOp());
Field<?> x = toField(parseOp());
if (agg && parse(')') || parseIf(')'))
return parseAggregateFunctionIf(false, bitXNorAgg((Field) x));
parse(',');
Field<?> y = toField(parseNumericOp());
Field<?> y = toField(parseOp());
parse(')');
return bitXNor((Field) x, (Field) y);
}
else if (parseKeywordIf("BIT_NOT", "BITNOT", "BIN_NOT", "BITWISE_NOT")) {
parse('(');
Field<?> x = toField(parseNumericOp());
Field<?> x = toField(parseOp());
parse(')');
return bitNot((Field) x);
}
else if (parseKeywordIf("BIN_SHL", "BITSHIFTLEFT", "BITWISE_LEFT_SHIFT")) {
parse('(');
Field<?> x = toField(parseNumericOp());
Field<?> x = toField(parseOp());
parse(',');
Field<?> y = toField(parseNumericOp());
Field<?> y = toField(parseOp());
parse(')');
return shl((Field) x, (Field) y);
}
else if (parseKeywordIf("BIN_SHR", "BITSHIFTRIGHT", "BITWISE_RIGHT_SHIFT")) {
parse('(');
Field<?> x = toField(parseNumericOp());
Field<?> x = toField(parseOp());
parse(',');
Field<?> y = toField(parseNumericOp());
Field<?> y = toField(parseOp());
parse(')');
return shr((Field) x, (Field) y);
@ -10690,8 +10701,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
private final Field<?> parseFieldLogIf() {
if (parseFunctionNameIf("LOG")) {
parse('(');
Field f1 = toField(parseNumericOp());
Field f2 = parseIf(',') ? toField(parseNumericOp()) : null;
Field f1 = toField(parseOp());
Field f2 = parseIf(',') ? toField(parseOp()) : null;
parse(')');
switch (parseFamily()) {
@ -10752,7 +10763,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
return DSL.trunc((Field) arg1, p);
}
else {
Field<?> arg2 = toField(parseNumericOp());
Field<?> arg2 = toField(parseOp());
parse(')');
return DSL.trunc((Field) arg1, (Field) arg2);
}
@ -10779,8 +10790,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
private final Field<?> parseFieldRoundIf() {
if (parseFunctionNameIf("ROUND")) {
parse('(');
Field arg1 = toField(parseNumericOp());
Field arg2 = parseIf(',') ? toField(parseNumericOp()) : null;
Field arg1 = toField(parseOp());
Field arg2 = parseIf(',') ? toField(parseOp()) : null;
parse(')');
return arg2 == null ? round(arg1) : round(arg1, arg2);
@ -11836,10 +11847,10 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
Field f1 = parseField();
if (substr || !(keywords = parseKeywordIf("FROM")))
parse(',');
Field f2 = toField(parseNumericOp());
Field f2 = toField(parseOp());
Field f3 =
((keywords && parseKeywordIf("FOR")) || (!keywords && parseIf(',')))
? (Field) toField(parseNumericOp())
? (Field) toField(parseOp())
: null;
parse(')');

View File

@ -7472,6 +7472,78 @@ public final class QOM {
@NotNull default JSONBArrayLength $field(Field<JSONB> newField) { return $arg1(newField); }
}
/**
* The <code>JSON KEY EXISTS</code> function.
* <p>
* Check if a key exists in a JSON object
*/
public /*sealed*/ interface JSONKeyExists
extends
UOperator2<Field<JSON>, Field<String>, JSONKeyExists>,
org.jooq.Condition
//permits
// JSONKeyExists
{
/**
* The JSON object
*/
@NotNull default Field<JSON> $json() { return $arg1(); }
/**
* The JSON object
*/
@CheckReturnValue
@NotNull default JSONKeyExists $json(Field<JSON> newJson) { return $arg1(newJson); }
/**
* The key in the JSON object
*/
@NotNull default Field<String> $key() { return $arg2(); }
/**
* The key in the JSON object
*/
@CheckReturnValue
@NotNull default JSONKeyExists $key(Field<String> newKey) { return $arg2(newKey); }
}
/**
* The <code>JSONB KEY EXISTS</code> function.
* <p>
* Check if a key exists in a JSONB object
*/
public /*sealed*/ interface JSONBKeyExists
extends
UOperator2<Field<JSONB>, Field<String>, JSONBKeyExists>,
org.jooq.Condition
//permits
// JSONBKeyExists
{
/**
* The JSONB object
*/
@NotNull default Field<JSONB> $json() { return $arg1(); }
/**
* The JSONB object
*/
@CheckReturnValue
@NotNull default JSONBKeyExists $json(Field<JSONB> newJson) { return $arg1(newJson); }
/**
* The key in the JSONB object
*/
@NotNull default Field<String> $key() { return $arg2(); }
/**
* The key in the JSONB object
*/
@CheckReturnValue
@NotNull default JSONBKeyExists $key(Field<String> newKey) { return $arg2(newKey); }
}
/**
* The <code>JSON KEYS</code> function.
* <p>