[jOOQ/jOOQ#10018] Add support for PostgreSQL's JSON/JSONB -> and ->> operators
This commit is contained in:
parent
f5c067338e
commit
90eb7a172e
@ -20182,6 +20182,418 @@ public class DSL {
|
||||
return new JSONObject(SQLDataType.JSONB, new QueryPartList<>(entries));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ELEMENT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSON array expression.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
* @param index is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSON> jsonGetElement(JSON field, int index) {
|
||||
return new JSONGetElement(Tools.field(field), Tools.field(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ELEMENT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSON array expression.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSON> jsonGetElement(JSON field, Field<Integer> index) {
|
||||
return new JSONGetElement(Tools.field(field), index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ELEMENT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSON array expression.
|
||||
*
|
||||
* @param index is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSON> jsonGetElement(Field<JSON> field, int index) {
|
||||
return new JSONGetElement(field, Tools.field(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ELEMENT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSON array expression.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSON> jsonGetElement(Field<JSON> field, Field<Integer> index) {
|
||||
return new JSONGetElement(field, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ELEMENT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSONB array expression.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
* @param index is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSONB> jsonbGetElement(JSONB field, int index) {
|
||||
return new JSONBGetElement(Tools.field(field), Tools.field(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ELEMENT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSONB array expression.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSONB> jsonbGetElement(JSONB field, Field<Integer> index) {
|
||||
return new JSONBGetElement(Tools.field(field), index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ELEMENT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSONB array expression.
|
||||
*
|
||||
* @param index is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSONB> jsonbGetElement(Field<JSONB> field, int index) {
|
||||
return new JSONBGetElement(field, Tools.field(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ELEMENT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSONB array expression.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSONB> jsonbGetElement(Field<JSONB> field, Field<Integer> index) {
|
||||
return new JSONBGetElement(field, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ELEMENT_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSON array expression and return it as a string.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
* @param index is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonGetElementAsText(JSON field, int index) {
|
||||
return new JSONGetElementAsText(Tools.field(field), Tools.field(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ELEMENT_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSON array expression and return it as a string.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonGetElementAsText(JSON field, Field<Integer> index) {
|
||||
return new JSONGetElementAsText(Tools.field(field), index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ELEMENT_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSON array expression and return it as a string.
|
||||
*
|
||||
* @param index is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonGetElementAsText(Field<JSON> field, int index) {
|
||||
return new JSONGetElementAsText(field, Tools.field(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ELEMENT_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSON array expression and return it as a string.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonGetElementAsText(Field<JSON> field, Field<Integer> index) {
|
||||
return new JSONGetElementAsText(field, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ELEMENT_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSONB array expression and return it as a string.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
* @param index is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonbGetElementAsText(JSONB field, int index) {
|
||||
return new JSONBGetElementAsText(Tools.field(field), Tools.field(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ELEMENT_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSONB array expression and return it as a string.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonbGetElementAsText(JSONB field, Field<Integer> index) {
|
||||
return new JSONBGetElementAsText(Tools.field(field), index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ELEMENT_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSONB array expression and return it as a string.
|
||||
*
|
||||
* @param index is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonbGetElementAsText(Field<JSONB> field, int index) {
|
||||
return new JSONBGetElementAsText(field, Tools.field(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ELEMENT_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSONB array expression and return it as a string.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonbGetElementAsText(Field<JSONB> field, Field<Integer> index) {
|
||||
return new JSONBGetElementAsText(field, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ATTRIBUTE</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSON object expression.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
* @param attribute is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSON> jsonGetAttribute(JSON field, @Stringly.Param String attribute) {
|
||||
return new JSONGetAttribute(Tools.field(field), Tools.field(attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ATTRIBUTE</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSON object expression.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSON> jsonGetAttribute(JSON field, Field<String> attribute) {
|
||||
return new JSONGetAttribute(Tools.field(field), attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ATTRIBUTE</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSON object expression.
|
||||
*
|
||||
* @param attribute is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSON> jsonGetAttribute(Field<JSON> field, @Stringly.Param String attribute) {
|
||||
return new JSONGetAttribute(field, Tools.field(attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ATTRIBUTE</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSON object expression.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSON> jsonGetAttribute(Field<JSON> field, Field<String> attribute) {
|
||||
return new JSONGetAttribute(field, attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ATTRIBUTE</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSONB object expression.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
* @param attribute is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSONB> jsonbGetAttribute(JSONB field, @Stringly.Param String attribute) {
|
||||
return new JSONBGetAttribute(Tools.field(field), Tools.field(attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ATTRIBUTE</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSONB object expression.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSONB> jsonbGetAttribute(JSONB field, Field<String> attribute) {
|
||||
return new JSONBGetAttribute(Tools.field(field), attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ATTRIBUTE</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSONB object expression.
|
||||
*
|
||||
* @param attribute is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSONB> jsonbGetAttribute(Field<JSONB> field, @Stringly.Param String attribute) {
|
||||
return new JSONBGetAttribute(field, Tools.field(attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ATTRIBUTE</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSONB object expression.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<JSONB> jsonbGetAttribute(Field<JSONB> field, Field<String> attribute) {
|
||||
return new JSONBGetAttribute(field, attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ATTRIBUTE_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSON object expression and return it as string.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
* @param attribute is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonGetAttributeAsText(JSON field, @Stringly.Param String attribute) {
|
||||
return new JSONGetAttributeAsText(Tools.field(field), Tools.field(attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ATTRIBUTE_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSON object expression and return it as string.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonGetAttributeAsText(JSON field, Field<String> attribute) {
|
||||
return new JSONGetAttributeAsText(Tools.field(field), attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ATTRIBUTE_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSON object expression and return it as string.
|
||||
*
|
||||
* @param attribute is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonGetAttributeAsText(Field<JSON> field, @Stringly.Param String attribute) {
|
||||
return new JSONGetAttributeAsText(field, Tools.field(attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON_GET_ATTRIBUTE_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSON object expression and return it as string.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonGetAttributeAsText(Field<JSON> field, Field<String> attribute) {
|
||||
return new JSONGetAttributeAsText(field, attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ATTRIBUTE_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSONB object expression and return it as
|
||||
* string.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
* @param attribute is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonbGetAttributeAsText(JSONB field, @Stringly.Param String attribute) {
|
||||
return new JSONBGetAttributeAsText(Tools.field(field), Tools.field(attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ATTRIBUTE_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSONB object expression and return it as
|
||||
* string.
|
||||
*
|
||||
* @param field is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonbGetAttributeAsText(JSONB field, Field<String> attribute) {
|
||||
return new JSONBGetAttributeAsText(Tools.field(field), attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ATTRIBUTE_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSONB object expression and return it as
|
||||
* string.
|
||||
*
|
||||
* @param attribute is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonbGetAttributeAsText(Field<JSONB> field, @Stringly.Param String attribute) {
|
||||
return new JSONBGetAttributeAsText(field, Tools.field(attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB_GET_ATTRIBUTE_AS_TEXT</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSONB object expression and return it as
|
||||
* string.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
public static Field<String> jsonbGetAttributeAsText(Field<JSONB> field, Field<String> attribute) {
|
||||
return new JSONBGetAttributeAsText(field, attribute);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@ import org.jooq.Keyword;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.impl.QOM.Aliasable;
|
||||
import org.jooq.impl.QOM.UNotYetImplemented;
|
||||
|
||||
/**
|
||||
@ -105,4 +106,18 @@ final class HintedTable<R extends Record> extends AbstractTable<R> implements UN
|
||||
final FieldsImpl<R> fields0() {
|
||||
return delegate.fields0();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Table<R> $aliased() {
|
||||
return new HintedTable<R>((AbstractTable<R>) ((Aliasable<Table<R>>) delegate).$aliased(), keywords, arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Name $alias() {
|
||||
return ((Aliasable<Table<R>>) delegate).$alias();
|
||||
}
|
||||
}
|
||||
|
||||
217
jOOQ/src/main/java/org/jooq/impl/JSONBGetAttribute.java
Normal file
217
jOOQ/src/main/java/org/jooq/impl/JSONBGetAttribute.java
Normal file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://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: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
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.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.impl.QOM.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>JSONB GET ATTRIBUTE</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class JSONBGetAttribute
|
||||
extends
|
||||
AbstractField<JSONB>
|
||||
implements
|
||||
QOM.JSONBGetAttribute
|
||||
{
|
||||
|
||||
final Field<JSONB> field;
|
||||
final Field<String> attribute;
|
||||
|
||||
JSONBGetAttribute(
|
||||
Field<JSONB> field,
|
||||
Field<String> attribute
|
||||
) {
|
||||
super(
|
||||
N_JSONB_GET_ATTRIBUTE,
|
||||
allNotNull(JSONB, field, attribute)
|
||||
);
|
||||
|
||||
this.field = nullSafeNotNull(field, JSONB);
|
||||
this.attribute = nullSafeNotNull(attribute, VARCHAR);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
case SQLITE:
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSONB, field, inline("$.").concat(attribute)));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.sql('(').visit(field).sql("->").visit(attribute).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<JSONB> $field() {
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<String> $attribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONBGetAttribute $field(Field<JSONB> newValue) {
|
||||
return $constructor().apply(newValue, $attribute());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONBGetAttribute $attribute(Field<String> newValue) {
|
||||
return $constructor().apply($field(), newValue);
|
||||
}
|
||||
|
||||
public final Function2<? super Field<JSONB>, ? super Field<String>, ? extends QOM.JSONBGetAttribute> $constructor() {
|
||||
return (a1, a2) -> new JSONBGetAttribute(a1, a2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof QOM.JSONBGetAttribute o) {
|
||||
return
|
||||
StringUtils.equals($field(), o.$field()) &&
|
||||
StringUtils.equals($attribute(), o.$attribute())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
217
jOOQ/src/main/java/org/jooq/impl/JSONBGetAttributeAsText.java
Normal file
217
jOOQ/src/main/java/org/jooq/impl/JSONBGetAttributeAsText.java
Normal file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://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: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
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.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.impl.QOM.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>JSONB GET ATTRIBUTE AS TEXT</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class JSONBGetAttributeAsText
|
||||
extends
|
||||
AbstractField<String>
|
||||
implements
|
||||
QOM.JSONBGetAttributeAsText
|
||||
{
|
||||
|
||||
final Field<JSONB> field;
|
||||
final Field<String> attribute;
|
||||
|
||||
JSONBGetAttributeAsText(
|
||||
Field<JSONB> field,
|
||||
Field<String> attribute
|
||||
) {
|
||||
super(
|
||||
N_JSONB_GET_ATTRIBUTE_AS_TEXT,
|
||||
allNotNull(VARCHAR, field, attribute)
|
||||
);
|
||||
|
||||
this.field = nullSafeNotNull(field, JSONB);
|
||||
this.attribute = nullSafeNotNull(attribute, VARCHAR);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
case SQLITE:
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSONB, field, inline("$.").concat(attribute)));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.sql('(').visit(field).sql("->>").visit(attribute).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<JSONB> $field() {
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<String> $attribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONBGetAttributeAsText $field(Field<JSONB> newValue) {
|
||||
return $constructor().apply(newValue, $attribute());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONBGetAttributeAsText $attribute(Field<String> newValue) {
|
||||
return $constructor().apply($field(), newValue);
|
||||
}
|
||||
|
||||
public final Function2<? super Field<JSONB>, ? super Field<String>, ? extends QOM.JSONBGetAttributeAsText> $constructor() {
|
||||
return (a1, a2) -> new JSONBGetAttributeAsText(a1, a2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof QOM.JSONBGetAttributeAsText o) {
|
||||
return
|
||||
StringUtils.equals($field(), o.$field()) &&
|
||||
StringUtils.equals($attribute(), o.$attribute())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
217
jOOQ/src/main/java/org/jooq/impl/JSONBGetElement.java
Normal file
217
jOOQ/src/main/java/org/jooq/impl/JSONBGetElement.java
Normal file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://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: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
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.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.impl.QOM.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>JSONB GET ELEMENT</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class JSONBGetElement
|
||||
extends
|
||||
AbstractField<JSONB>
|
||||
implements
|
||||
QOM.JSONBGetElement
|
||||
{
|
||||
|
||||
final Field<JSONB> field;
|
||||
final Field<Integer> index;
|
||||
|
||||
JSONBGetElement(
|
||||
Field<JSONB> field,
|
||||
Field<Integer> index
|
||||
) {
|
||||
super(
|
||||
N_JSONB_GET_ELEMENT,
|
||||
allNotNull(JSONB, field, index)
|
||||
);
|
||||
|
||||
this.field = nullSafeNotNull(field, JSONB);
|
||||
this.index = nullSafeNotNull(index, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
case SQLITE:
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSONB, field, inline("$[").concat(index).concat(inline("]"))));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.sql('(').visit(field).sql("->").visit(index).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<JSONB> $field() {
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<Integer> $index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONBGetElement $field(Field<JSONB> newValue) {
|
||||
return $constructor().apply(newValue, $index());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONBGetElement $index(Field<Integer> newValue) {
|
||||
return $constructor().apply($field(), newValue);
|
||||
}
|
||||
|
||||
public final Function2<? super Field<JSONB>, ? super Field<Integer>, ? extends QOM.JSONBGetElement> $constructor() {
|
||||
return (a1, a2) -> new JSONBGetElement(a1, a2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof QOM.JSONBGetElement o) {
|
||||
return
|
||||
StringUtils.equals($field(), o.$field()) &&
|
||||
StringUtils.equals($index(), o.$index())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
217
jOOQ/src/main/java/org/jooq/impl/JSONBGetElementAsText.java
Normal file
217
jOOQ/src/main/java/org/jooq/impl/JSONBGetElementAsText.java
Normal file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://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: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
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.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.impl.QOM.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>JSONB GET ELEMENT AS TEXT</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class JSONBGetElementAsText
|
||||
extends
|
||||
AbstractField<String>
|
||||
implements
|
||||
QOM.JSONBGetElementAsText
|
||||
{
|
||||
|
||||
final Field<JSONB> field;
|
||||
final Field<Integer> index;
|
||||
|
||||
JSONBGetElementAsText(
|
||||
Field<JSONB> field,
|
||||
Field<Integer> index
|
||||
) {
|
||||
super(
|
||||
N_JSONB_GET_ELEMENT_AS_TEXT,
|
||||
allNotNull(VARCHAR, field, index)
|
||||
);
|
||||
|
||||
this.field = nullSafeNotNull(field, JSONB);
|
||||
this.index = nullSafeNotNull(index, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
case SQLITE:
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSONB, field, inline("$[").concat(index).concat(inline("]"))));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.sql('(').visit(field).sql("->>").visit(index).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<JSONB> $field() {
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<Integer> $index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONBGetElementAsText $field(Field<JSONB> newValue) {
|
||||
return $constructor().apply(newValue, $index());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONBGetElementAsText $index(Field<Integer> newValue) {
|
||||
return $constructor().apply($field(), newValue);
|
||||
}
|
||||
|
||||
public final Function2<? super Field<JSONB>, ? super Field<Integer>, ? extends QOM.JSONBGetElementAsText> $constructor() {
|
||||
return (a1, a2) -> new JSONBGetElementAsText(a1, a2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof QOM.JSONBGetElementAsText o) {
|
||||
return
|
||||
StringUtils.equals($field(), o.$field()) &&
|
||||
StringUtils.equals($index(), o.$index())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
217
jOOQ/src/main/java/org/jooq/impl/JSONGetAttribute.java
Normal file
217
jOOQ/src/main/java/org/jooq/impl/JSONGetAttribute.java
Normal file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://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: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
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.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.impl.QOM.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>JSON GET ATTRIBUTE</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class JSONGetAttribute
|
||||
extends
|
||||
AbstractField<JSON>
|
||||
implements
|
||||
QOM.JSONGetAttribute
|
||||
{
|
||||
|
||||
final Field<JSON> field;
|
||||
final Field<String> attribute;
|
||||
|
||||
JSONGetAttribute(
|
||||
Field<JSON> field,
|
||||
Field<String> attribute
|
||||
) {
|
||||
super(
|
||||
N_JSON_GET_ATTRIBUTE,
|
||||
allNotNull(JSON, field, attribute)
|
||||
);
|
||||
|
||||
this.field = nullSafeNotNull(field, JSON);
|
||||
this.attribute = nullSafeNotNull(attribute, VARCHAR);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
case SQLITE:
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSON, field, inline("$.").concat(attribute)));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.sql('(').visit(field).sql("->").visit(attribute).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<JSON> $field() {
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<String> $attribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONGetAttribute $field(Field<JSON> newValue) {
|
||||
return $constructor().apply(newValue, $attribute());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONGetAttribute $attribute(Field<String> newValue) {
|
||||
return $constructor().apply($field(), newValue);
|
||||
}
|
||||
|
||||
public final Function2<? super Field<JSON>, ? super Field<String>, ? extends QOM.JSONGetAttribute> $constructor() {
|
||||
return (a1, a2) -> new JSONGetAttribute(a1, a2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof QOM.JSONGetAttribute o) {
|
||||
return
|
||||
StringUtils.equals($field(), o.$field()) &&
|
||||
StringUtils.equals($attribute(), o.$attribute())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
217
jOOQ/src/main/java/org/jooq/impl/JSONGetAttributeAsText.java
Normal file
217
jOOQ/src/main/java/org/jooq/impl/JSONGetAttributeAsText.java
Normal file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://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: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
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.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.impl.QOM.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>JSON GET ATTRIBUTE AS TEXT</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class JSONGetAttributeAsText
|
||||
extends
|
||||
AbstractField<String>
|
||||
implements
|
||||
QOM.JSONGetAttributeAsText
|
||||
{
|
||||
|
||||
final Field<JSON> field;
|
||||
final Field<String> attribute;
|
||||
|
||||
JSONGetAttributeAsText(
|
||||
Field<JSON> field,
|
||||
Field<String> attribute
|
||||
) {
|
||||
super(
|
||||
N_JSON_GET_ATTRIBUTE_AS_TEXT,
|
||||
allNotNull(VARCHAR, field, attribute)
|
||||
);
|
||||
|
||||
this.field = nullSafeNotNull(field, JSON);
|
||||
this.attribute = nullSafeNotNull(attribute, VARCHAR);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
case SQLITE:
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSON, field, inline("$.").concat(attribute)));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.sql('(').visit(field).sql("->>").visit(attribute).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<JSON> $field() {
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<String> $attribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONGetAttributeAsText $field(Field<JSON> newValue) {
|
||||
return $constructor().apply(newValue, $attribute());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONGetAttributeAsText $attribute(Field<String> newValue) {
|
||||
return $constructor().apply($field(), newValue);
|
||||
}
|
||||
|
||||
public final Function2<? super Field<JSON>, ? super Field<String>, ? extends QOM.JSONGetAttributeAsText> $constructor() {
|
||||
return (a1, a2) -> new JSONGetAttributeAsText(a1, a2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof QOM.JSONGetAttributeAsText o) {
|
||||
return
|
||||
StringUtils.equals($field(), o.$field()) &&
|
||||
StringUtils.equals($attribute(), o.$attribute())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
217
jOOQ/src/main/java/org/jooq/impl/JSONGetElement.java
Normal file
217
jOOQ/src/main/java/org/jooq/impl/JSONGetElement.java
Normal file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://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: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
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.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.impl.QOM.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>JSON GET ELEMENT</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class JSONGetElement
|
||||
extends
|
||||
AbstractField<JSON>
|
||||
implements
|
||||
QOM.JSONGetElement
|
||||
{
|
||||
|
||||
final Field<JSON> field;
|
||||
final Field<Integer> index;
|
||||
|
||||
JSONGetElement(
|
||||
Field<JSON> field,
|
||||
Field<Integer> index
|
||||
) {
|
||||
super(
|
||||
N_JSON_GET_ELEMENT,
|
||||
allNotNull(JSON, field, index)
|
||||
);
|
||||
|
||||
this.field = nullSafeNotNull(field, JSON);
|
||||
this.index = nullSafeNotNull(index, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
case SQLITE:
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSON, field, inline("$[").concat(index).concat(inline("]"))));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.sql('(').visit(field).sql("->").visit(index).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<JSON> $field() {
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<Integer> $index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONGetElement $field(Field<JSON> newValue) {
|
||||
return $constructor().apply(newValue, $index());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONGetElement $index(Field<Integer> newValue) {
|
||||
return $constructor().apply($field(), newValue);
|
||||
}
|
||||
|
||||
public final Function2<? super Field<JSON>, ? super Field<Integer>, ? extends QOM.JSONGetElement> $constructor() {
|
||||
return (a1, a2) -> new JSONGetElement(a1, a2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof QOM.JSONGetElement o) {
|
||||
return
|
||||
StringUtils.equals($field(), o.$field()) &&
|
||||
StringUtils.equals($index(), o.$index())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
217
jOOQ/src/main/java/org/jooq/impl/JSONGetElementAsText.java
Normal file
217
jOOQ/src/main/java/org/jooq/impl/JSONGetElementAsText.java
Normal file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://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: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
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.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.impl.QOM.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>JSON GET ELEMENT AS TEXT</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class JSONGetElementAsText
|
||||
extends
|
||||
AbstractField<String>
|
||||
implements
|
||||
QOM.JSONGetElementAsText
|
||||
{
|
||||
|
||||
final Field<JSON> field;
|
||||
final Field<Integer> index;
|
||||
|
||||
JSONGetElementAsText(
|
||||
Field<JSON> field,
|
||||
Field<Integer> index
|
||||
) {
|
||||
super(
|
||||
N_JSON_GET_ELEMENT_AS_TEXT,
|
||||
allNotNull(VARCHAR, field, index)
|
||||
);
|
||||
|
||||
this.field = nullSafeNotNull(field, JSON);
|
||||
this.index = nullSafeNotNull(index, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
case SQLITE:
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSON, field, inline("$[").concat(index).concat(inline("]"))));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.sql('(').visit(field).sql("->>").visit(index).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: Query Object Model
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Field<JSON> $field() {
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<Integer> $index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONGetElementAsText $field(Field<JSON> newValue) {
|
||||
return $constructor().apply(newValue, $index());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.JSONGetElementAsText $index(Field<Integer> newValue) {
|
||||
return $constructor().apply($field(), newValue);
|
||||
}
|
||||
|
||||
public final Function2<? super Field<JSON>, ? super Field<Integer>, ? extends QOM.JSONGetElementAsText> $constructor() {
|
||||
return (a1, a2) -> new JSONGetElementAsText(a1, a2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof QOM.JSONGetElementAsText o) {
|
||||
return
|
||||
StringUtils.equals($field(), o.$field()) &&
|
||||
StringUtils.equals($index(), o.$index())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
@ -392,8 +392,16 @@ final class Names {
|
||||
static final Name N_GOTO = systemName("goto");
|
||||
static final Name N_INSERTING = systemName("inserting");
|
||||
static final Name N_JSONB_ARRAY = systemName("jsonb_array");
|
||||
static final Name N_JSONB_GET_ATTRIBUTE = systemName("jsonb_get_attribute");
|
||||
static final Name N_JSONB_GET_ATTRIBUTE_AS_TEXT= systemName("jsonb_get_attribute_as_text");
|
||||
static final Name N_JSONB_GET_ELEMENT = systemName("jsonb_get_element");
|
||||
static final Name N_JSONB_GET_ELEMENT_AS_TEXT= systemName("jsonb_get_element_as_text");
|
||||
static final Name N_JSONB_OBJECT = systemName("jsonb_object");
|
||||
static final Name N_JSON_ARRAY = systemName("json_array");
|
||||
static final Name N_JSON_GET_ATTRIBUTE = systemName("json_get_attribute");
|
||||
static final Name N_JSON_GET_ATTRIBUTE_AS_TEXT= systemName("json_get_attribute_as_text");
|
||||
static final Name N_JSON_GET_ELEMENT = systemName("json_get_element");
|
||||
static final Name N_JSON_GET_ELEMENT_AS_TEXT= systemName("json_get_element_as_text");
|
||||
static final Name N_JSON_OBJECT = systemName("json_object");
|
||||
static final Name N_LEFT = systemName("left");
|
||||
static final Name N_LEVEL = systemName("level");
|
||||
|
||||
@ -197,12 +197,20 @@ import static org.jooq.impl.DSL.isoDayOfWeek;
|
||||
import static org.jooq.impl.DSL.jsonArray;
|
||||
import static org.jooq.impl.DSL.jsonArrayAgg;
|
||||
import static org.jooq.impl.DSL.jsonExists;
|
||||
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.jsonObject;
|
||||
import static org.jooq.impl.DSL.jsonObjectAgg;
|
||||
import static org.jooq.impl.DSL.jsonTable;
|
||||
import static org.jooq.impl.DSL.jsonValue;
|
||||
import static org.jooq.impl.DSL.jsonbArray;
|
||||
import static org.jooq.impl.DSL.jsonbArrayAgg;
|
||||
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.jsonbObject;
|
||||
import static org.jooq.impl.DSL.jsonbObjectAgg;
|
||||
import static org.jooq.impl.DSL.key;
|
||||
@ -593,6 +601,7 @@ import org.jooq.InsertOnDuplicateStep;
|
||||
import org.jooq.InsertReturningStep;
|
||||
import org.jooq.InsertSetStep;
|
||||
import org.jooq.InsertValuesStepN;
|
||||
import org.jooq.JSON;
|
||||
import org.jooq.JSONArrayAggNullStep;
|
||||
import org.jooq.JSONArrayAggOrderByStep;
|
||||
import org.jooq.JSONArrayAggReturningStep;
|
||||
@ -702,7 +711,6 @@ import org.jooq.impl.QOM.JSONOnNull;
|
||||
import org.jooq.impl.QOM.UEmpty;
|
||||
import org.jooq.impl.QOM.XMLPassingMechanism;
|
||||
import org.jooq.impl.ScopeStack.Value;
|
||||
import org.jooq.impl.Tools.BooleanDataKey;
|
||||
import org.jooq.tools.StringUtils;
|
||||
import org.jooq.tools.reflect.Reflect;
|
||||
import org.jooq.types.DayToSecond;
|
||||
@ -7734,18 +7742,54 @@ 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() {
|
||||
FieldOrRow r = parseSum();
|
||||
FieldOrRow l = parseSum();
|
||||
|
||||
if (r instanceof Field)
|
||||
if (l instanceof Field)
|
||||
for (;;)
|
||||
if (parseIf("<<"))
|
||||
r = ((Field) r).shl((Field) parseSum());
|
||||
l = ((Field) l).shl((Field) parseSum());
|
||||
else if (parseIf(">>"))
|
||||
r = ((Field) r).shr((Field) parseSum());
|
||||
l = ((Field) l).shr((Field) parseSum());
|
||||
else if (parseIf("->>")) {
|
||||
Field r = (Field) parseSum();
|
||||
|
||||
// [#10018] We cannot really know reliably whether this is a
|
||||
// index or attribute access. Let's default to the
|
||||
// more popular attribute access for now. Also,
|
||||
// JSONB is likely more popular than JSON.
|
||||
if (r.getDataType().isNumeric())
|
||||
if (((Field) l).getType() == JSON.class)
|
||||
l = jsonGetElementAsText((Field) l, r);
|
||||
else
|
||||
l = jsonbGetElementAsText((Field) l, r);
|
||||
else
|
||||
if (((Field) l).getType() == JSON.class)
|
||||
l = jsonGetAttributeAsText((Field) l, r);
|
||||
else
|
||||
l = jsonbGetAttributeAsText((Field) l, r);
|
||||
}
|
||||
else if (parseIf("->")) {
|
||||
Field r = (Field) parseSum();
|
||||
|
||||
// [#10018] We cannot really know reliably whether this is a
|
||||
// index or attribute access. Let's default to the
|
||||
// more popular attribute access for now. Also,
|
||||
// JSONB is likely more popular than JSON.
|
||||
if (r.getDataType().isNumeric())
|
||||
if (((Field) l).getType() == JSON.class)
|
||||
l = jsonGetElement((Field) l, r);
|
||||
else
|
||||
l = jsonbGetElement((Field) l, r);
|
||||
else
|
||||
if (((Field) l).getType() == JSON.class)
|
||||
l = jsonGetAttribute((Field) l, r);
|
||||
else
|
||||
l = jsonbGetAttribute((Field) l, r);
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
return r;
|
||||
return l;
|
||||
}
|
||||
|
||||
private final FieldOrRow parseSum() {
|
||||
@ -7755,7 +7799,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
for (;;)
|
||||
if (parseIf('+'))
|
||||
r = parseSumRightOperand(r, true);
|
||||
else if (parseIf('-'))
|
||||
else if (!peek("->") && parseIf('-'))
|
||||
r = parseSumRightOperand(r, false);
|
||||
else
|
||||
break;
|
||||
|
||||
@ -89,6 +89,8 @@ import org.jooq.Function9;
|
||||
import org.jooq.Geometry;
|
||||
import org.jooq.GroupField;
|
||||
import org.jooq.Index;
|
||||
import org.jooq.JSON;
|
||||
import org.jooq.JSONB;
|
||||
import org.jooq.JSONEntry;
|
||||
import org.jooq.Keyword;
|
||||
// ...
|
||||
@ -4535,6 +4537,143 @@ public final class QOM {
|
||||
@NotNull JSONObject<T> $returning(DataType<?> returning);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON GET ELEMENT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSON array expression.
|
||||
*/
|
||||
public /*sealed*/ interface JSONGetElement
|
||||
extends
|
||||
org.jooq.Field<JSON>
|
||||
//permits
|
||||
// JSONGetElement
|
||||
{
|
||||
@NotNull Field<JSON> $field();
|
||||
@NotNull Field<Integer> $index();
|
||||
@NotNull JSONGetElement $field(Field<JSON> field);
|
||||
@NotNull JSONGetElement $index(Field<Integer> index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB GET ELEMENT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSONB array expression.
|
||||
*/
|
||||
public /*sealed*/ interface JSONBGetElement
|
||||
extends
|
||||
org.jooq.Field<JSONB>
|
||||
//permits
|
||||
// JSONBGetElement
|
||||
{
|
||||
@NotNull Field<JSONB> $field();
|
||||
@NotNull Field<Integer> $index();
|
||||
@NotNull JSONBGetElement $field(Field<JSONB> field);
|
||||
@NotNull JSONBGetElement $index(Field<Integer> index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON GET ELEMENT AS TEXT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSON array expression and return it as a string.
|
||||
*/
|
||||
public /*sealed*/ interface JSONGetElementAsText
|
||||
extends
|
||||
org.jooq.Field<String>
|
||||
//permits
|
||||
// JSONGetElementAsText
|
||||
{
|
||||
@NotNull Field<JSON> $field();
|
||||
@NotNull Field<Integer> $index();
|
||||
@NotNull JSONGetElementAsText $field(Field<JSON> field);
|
||||
@NotNull JSONGetElementAsText $index(Field<Integer> index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB GET ELEMENT AS TEXT</code> function.
|
||||
* <p>
|
||||
* Access an array element from a JSONB array expression and return it as a string.
|
||||
*/
|
||||
public /*sealed*/ interface JSONBGetElementAsText
|
||||
extends
|
||||
org.jooq.Field<String>
|
||||
//permits
|
||||
// JSONBGetElementAsText
|
||||
{
|
||||
@NotNull Field<JSONB> $field();
|
||||
@NotNull Field<Integer> $index();
|
||||
@NotNull JSONBGetElementAsText $field(Field<JSONB> field);
|
||||
@NotNull JSONBGetElementAsText $index(Field<Integer> index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON GET ATTRIBUTE</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSON object expression.
|
||||
*/
|
||||
public /*sealed*/ interface JSONGetAttribute
|
||||
extends
|
||||
org.jooq.Field<JSON>
|
||||
//permits
|
||||
// JSONGetAttribute
|
||||
{
|
||||
@NotNull Field<JSON> $field();
|
||||
@NotNull Field<String> $attribute();
|
||||
@NotNull JSONGetAttribute $field(Field<JSON> field);
|
||||
@NotNull JSONGetAttribute $attribute(Field<String> attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB GET ATTRIBUTE</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSONB object expression.
|
||||
*/
|
||||
public /*sealed*/ interface JSONBGetAttribute
|
||||
extends
|
||||
org.jooq.Field<JSONB>
|
||||
//permits
|
||||
// JSONBGetAttribute
|
||||
{
|
||||
@NotNull Field<JSONB> $field();
|
||||
@NotNull Field<String> $attribute();
|
||||
@NotNull JSONBGetAttribute $field(Field<JSONB> field);
|
||||
@NotNull JSONBGetAttribute $attribute(Field<String> attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSON GET ATTRIBUTE AS TEXT</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSON object expression and return it as string.
|
||||
*/
|
||||
public /*sealed*/ interface JSONGetAttributeAsText
|
||||
extends
|
||||
org.jooq.Field<String>
|
||||
//permits
|
||||
// JSONGetAttributeAsText
|
||||
{
|
||||
@NotNull Field<JSON> $field();
|
||||
@NotNull Field<String> $attribute();
|
||||
@NotNull JSONGetAttributeAsText $field(Field<JSON> field);
|
||||
@NotNull JSONGetAttributeAsText $attribute(Field<String> attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>JSONB GET ATTRIBUTE AS TEXT</code> function.
|
||||
* <p>
|
||||
* Access an object attribute value from a JSONB object expression and return it as
|
||||
* string.
|
||||
*/
|
||||
public /*sealed*/ interface JSONBGetAttributeAsText
|
||||
extends
|
||||
org.jooq.Field<String>
|
||||
//permits
|
||||
// JSONBGetAttributeAsText
|
||||
{
|
||||
@NotNull Field<JSONB> $field();
|
||||
@NotNull Field<String> $attribute();
|
||||
@NotNull JSONBGetAttributeAsText $field(Field<JSONB> field);
|
||||
@NotNull JSONBGetAttributeAsText $attribute(Field<String> attribute);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -318,6 +318,7 @@ import org.jooq.WindowSpecification;
|
||||
import org.jooq.XML;
|
||||
import org.jooq.conf.BackslashEscaping;
|
||||
import org.jooq.conf.NestedCollectionEmulation;
|
||||
import org.jooq.conf.ParamType;
|
||||
import org.jooq.conf.ParseNameCase;
|
||||
import org.jooq.conf.RenderDefaultNullability;
|
||||
import org.jooq.conf.RenderMapping;
|
||||
@ -5792,6 +5793,13 @@ final class Tools {
|
||||
return VARCHAR(length).nullability(type.nullability()).defaultValue((Field) type.defaultValue());
|
||||
}
|
||||
|
||||
static final <C extends Context<? extends C>> C prependInline(C ctx, String prepend, Field<?> inline, String append) {
|
||||
if (inline instanceof Param<?> p)
|
||||
return ctx.visit(DSL.inline(prepend + p.getValue() + append));
|
||||
else
|
||||
return ctx.visit(DSL.inline(prepend).concat(inline).concat(DSL.inline(append)), ParamType.INLINED);
|
||||
}
|
||||
|
||||
static final <C extends Context<? extends C>> C prependSQL(C ctx, Query... queries) {
|
||||
return preOrAppendSQL(SimpleDataKey.DATA_PREPEND_SQL, ctx, queries);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user