[jOOQ/jOOQ#11485] Add support for Trino DB - WIP
This commit is contained in:
parent
35a5d3afd4
commit
d8341ce9ee
@ -540,6 +540,10 @@ class GenerationUtil {
|
||||
|
||||
|
||||
|
||||
{
|
||||
return new BaseType(t.replaceFirst("(?i:array\\((.*?)\\))", "$1"), u);
|
||||
}
|
||||
|
||||
|
||||
case POSTGRES:
|
||||
case YUGABYTEDB: {
|
||||
|
||||
@ -3167,6 +3167,9 @@ public abstract class AbstractDatabase implements Database {
|
||||
|
||||
|
||||
|
||||
return upper.startsWith("ARRAY(");
|
||||
|
||||
|
||||
case H2:
|
||||
case POSTGRES:
|
||||
case YUGABYTEDB:
|
||||
|
||||
@ -220,11 +220,8 @@ extends AbstractDefinition {
|
||||
if (typeName.contains("(")) {
|
||||
Matcher m = PRECISION_SCALE.matcher(typeName);
|
||||
|
||||
if (m.find()) {
|
||||
if (!StringUtils.isBlank(m.group(1))) {
|
||||
return Integer.valueOf(m.group(1));
|
||||
}
|
||||
}
|
||||
if (m.find() && !StringUtils.isBlank(m.group(1)))
|
||||
return Integer.valueOf(m.group(1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -234,11 +231,8 @@ extends AbstractDefinition {
|
||||
if (typeName.contains("(")) {
|
||||
Matcher m = PRECISION_SCALE.matcher(typeName);
|
||||
|
||||
if (m.find()) {
|
||||
if (!StringUtils.isBlank(m.group(2))) {
|
||||
return Integer.valueOf(m.group(2));
|
||||
}
|
||||
}
|
||||
if (m.find() && !StringUtils.isBlank(m.group(2)))
|
||||
return Integer.valueOf(m.group(2));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -67,6 +67,7 @@ import org.jooq.meta.sqlite.SQLiteDatabase;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import org.jooq.meta.yugabytedb.YugabyteDBDatabase;
|
||||
|
||||
/**
|
||||
@ -116,7 +117,8 @@ public class Databases {
|
||||
case MYSQL: result = MySQLDatabase.class; break;
|
||||
case POSTGRES: result = PostgresDatabase.class; break;
|
||||
case SQLITE: result = SQLiteDatabase.class; break;
|
||||
case YUGABYTEDB: result = YugabyteDBDatabase.class; break;
|
||||
result = TrinoDatabase.class; break;
|
||||
case YUGABYTEDB: result = YugabyteDBDatabase.class; break;
|
||||
|
||||
case DEFAULT: result = JDBCDatabase.class; break;
|
||||
}
|
||||
|
||||
192
jOOQ-meta/src/main/java/org/jooq/meta/trino/TrinoDatabase.java
Normal file
192
jOOQ-meta/src/main/java/org/jooq/meta/trino/TrinoDatabase.java
Normal file
@ -0,0 +1,192 @@
|
||||
/*
|
||||
* 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.meta.trino;
|
||||
|
||||
import static org.jooq.Records.mapping;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.when;
|
||||
import static org.jooq.meta.hsqldb.information_schema.Tables.SCHEMATA;
|
||||
import static org.jooq.meta.hsqldb.information_schema.Tables.TABLES;
|
||||
import static org.jooq.meta.hsqldb.information_schema.Tables.VIEWS;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Record12;
|
||||
import org.jooq.Record6;
|
||||
import org.jooq.ResultQuery;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.TableOptions.TableType;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.meta.AbstractDatabase;
|
||||
import org.jooq.meta.ArrayDefinition;
|
||||
import org.jooq.meta.CatalogDefinition;
|
||||
import org.jooq.meta.DefaultRelations;
|
||||
import org.jooq.meta.DomainDefinition;
|
||||
import org.jooq.meta.EnumDefinition;
|
||||
import org.jooq.meta.PackageDefinition;
|
||||
import org.jooq.meta.RoutineDefinition;
|
||||
import org.jooq.meta.SchemaDefinition;
|
||||
import org.jooq.meta.SequenceDefinition;
|
||||
import org.jooq.meta.TableDefinition;
|
||||
import org.jooq.meta.UDTDefinition;
|
||||
import org.jooq.meta.XMLSchemaCollectionDefinition;
|
||||
import org.jooq.meta.hsqldb.HSQLDBDatabase;
|
||||
|
||||
/**
|
||||
* The Trino database
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public class TrinoDatabase extends AbstractDatabase {
|
||||
|
||||
@Override
|
||||
protected DSLContext create0() {
|
||||
return DSL.using(getConnection(), SQLDialect.TRINO);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TableDefinition> getTables0() throws SQLException {
|
||||
List<TableDefinition> result = new ArrayList<>();
|
||||
|
||||
for (Record record : create()
|
||||
.select(
|
||||
TABLES.TABLE_SCHEMA,
|
||||
TABLES.TABLE_NAME,
|
||||
when(TABLES.TABLE_TYPE.eq(inline("VIEW")), inline(TableType.VIEW.name()))
|
||||
.else_(inline(TableType.TABLE.name())).trim().as("table_type"),
|
||||
when(VIEWS.VIEW_DEFINITION.lower().like(inline("create%")), VIEWS.VIEW_DEFINITION)
|
||||
.else_(inline("create view \"").concat(TABLES.TABLE_NAME).concat("\" as ").concat(VIEWS.VIEW_DEFINITION)).as(VIEWS.VIEW_DEFINITION)
|
||||
)
|
||||
.from(TABLES)
|
||||
.leftJoin(VIEWS)
|
||||
.on(TABLES.TABLE_SCHEMA.eq(VIEWS.TABLE_SCHEMA))
|
||||
.and(TABLES.TABLE_NAME.eq(VIEWS.TABLE_NAME))
|
||||
.where(TABLES.TABLE_SCHEMA.in(getInputSchemata()))
|
||||
.orderBy(
|
||||
TABLES.TABLE_SCHEMA,
|
||||
TABLES.TABLE_NAME)
|
||||
) {
|
||||
SchemaDefinition schema = getSchema(record.get(TABLES.TABLE_SCHEMA));
|
||||
String name = record.get(TABLES.TABLE_NAME);
|
||||
String comment = "";
|
||||
TableType tableType = record.get("table_type", TableType.class);
|
||||
String source = record.get(VIEWS.VIEW_DEFINITION);
|
||||
|
||||
result.add(new TrinoTableDefinition(schema, name, comment, tableType, source));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadPrimaryKeys(DefaultRelations relations) throws SQLException {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadUniqueKeys(DefaultRelations relations) throws SQLException {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadForeignKeys(DefaultRelations relations) throws SQLException {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadCheckConstraints(DefaultRelations relations) throws SQLException {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<DomainDefinition> getDomains0() throws SQLException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<CatalogDefinition> getCatalogs0() throws SQLException {
|
||||
List<CatalogDefinition> result = new ArrayList<>();
|
||||
result.add(new CatalogDefinition(this, "", ""));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<SchemaDefinition> getSchemata0() throws SQLException {
|
||||
return
|
||||
create().select(SCHEMATA.SCHEMA_NAME)
|
||||
.from(SCHEMATA)
|
||||
.fetch(mapping(s -> new SchemaDefinition(this, s, "")));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<SequenceDefinition> getSequences0() throws SQLException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<RoutineDefinition> getRoutines0() throws SQLException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<PackageDefinition> getPackages0() throws SQLException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<EnumDefinition> getEnums0() throws SQLException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<UDTDefinition> getUDTs0() throws SQLException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ArrayDefinition> getArrays0() throws SQLException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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.meta.trino;
|
||||
|
||||
import static org.jooq.meta.hsqldb.information_schema.Tables.COLUMNS;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.Record;
|
||||
import org.jooq.TableOptions.TableType;
|
||||
import org.jooq.meta.AbstractTableDefinition;
|
||||
import org.jooq.meta.ColumnDefinition;
|
||||
import org.jooq.meta.DataTypeDefinition;
|
||||
import org.jooq.meta.DefaultColumnDefinition;
|
||||
import org.jooq.meta.DefaultDataTypeDefinition;
|
||||
import org.jooq.meta.SchemaDefinition;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public class TrinoTableDefinition extends AbstractTableDefinition {
|
||||
|
||||
public TrinoTableDefinition(SchemaDefinition schema, String name, String comment) {
|
||||
super(schema, name, comment);
|
||||
}
|
||||
|
||||
public TrinoTableDefinition(SchemaDefinition schema, String name, String comment, TableType tableType, String source) {
|
||||
super(schema, name, comment, tableType, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ColumnDefinition> getElements0() throws SQLException {
|
||||
List<ColumnDefinition> result = new ArrayList<>();
|
||||
|
||||
for (Record record : create().select(
|
||||
COLUMNS.COLUMN_NAME,
|
||||
COLUMNS.ORDINAL_POSITION,
|
||||
COLUMNS.DATA_TYPE,
|
||||
COLUMNS.COLUMN_DEFAULT,
|
||||
COLUMNS.IS_NULLABLE)
|
||||
.from(COLUMNS)
|
||||
.where(COLUMNS.TABLE_SCHEMA.eq(getSchema().getName()))
|
||||
.and(COLUMNS.TABLE_NAME.eq(getName()))
|
||||
.orderBy(COLUMNS.ORDINAL_POSITION)
|
||||
) {
|
||||
String typeName = record.get(COLUMNS.DATA_TYPE);
|
||||
Number precision = parsePrecision(typeName);
|
||||
Number scale = parseScale(typeName);
|
||||
|
||||
|
||||
DataTypeDefinition type = new DefaultDataTypeDefinition(
|
||||
getDatabase(),
|
||||
getSchema(),
|
||||
typeName,
|
||||
precision,
|
||||
precision,
|
||||
scale,
|
||||
record.get(COLUMNS.IS_NULLABLE, boolean.class),
|
||||
record.get(COLUMNS.COLUMN_DEFAULT)
|
||||
);
|
||||
|
||||
result.add(new DefaultColumnDefinition(
|
||||
getDatabase().getTable(getSchema(), getName()),
|
||||
record.get(COLUMNS.COLUMN_NAME),
|
||||
result.size() + 1,
|
||||
type,
|
||||
false,
|
||||
""
|
||||
));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -73,6 +73,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
@ -189,6 +190,7 @@ public @interface Allow {
|
||||
MYSQL,
|
||||
POSTGRES,
|
||||
SQLITE,
|
||||
TRINO,
|
||||
YUGABYTEDB
|
||||
};
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -73,6 +73,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ -59,6 +59,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@ import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -50,6 +50,7 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
@ -50,6 +50,7 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
@ -49,6 +49,7 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
@ -72,6 +72,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
@ -62,6 +62,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@ -58,6 +58,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -499,6 +499,11 @@ public enum SQLDialect {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Trino dialect family.
|
||||
*/
|
||||
TRINO("Trino", true, true),
|
||||
|
||||
/**
|
||||
* The YugabyteDB dialect family.
|
||||
|
||||
@ -65,6 +65,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -59,6 +59,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -147,5 +147,6 @@ import org.jetbrains.annotations.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -134,5 +134,6 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -52,6 +52,7 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
/**
|
||||
|
||||
@ -71,6 +71,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
@ -67,6 +67,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
/**
|
||||
|
||||
@ -66,6 +66,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -68,6 +68,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
/**
|
||||
|
||||
@ -60,6 +60,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -77,6 +77,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -65,6 +65,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -59,6 +59,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -50,6 +50,8 @@ import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
@ -59,6 +61,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
/**
|
||||
@ -127,6 +130,6 @@ public interface SelectWithTiesAfterOffsetStep<R extends Record> extends SelectF
|
||||
* Add the <code>WITH TIES</code> clause to a <code>LIMIT</code> clause.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ CUBRID, FIREBIRD, H2, POSTGRES, YUGABYTEDB })
|
||||
@Support({ CUBRID, FIREBIRD, H2, MARIADB, MYSQL, POSTGRES, YUGABYTEDB })
|
||||
SelectForUpdateStep<R> withTies();
|
||||
}
|
||||
|
||||
@ -58,6 +58,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -77,6 +77,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@ -59,6 +59,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -51,6 +51,7 @@ import static org.jooq.SQLDialect.H2;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* This type is used for the window function DSL API.
|
||||
|
||||
@ -60,6 +60,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -62,6 +62,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -60,6 +60,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -58,6 +58,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -61,6 +61,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -60,6 +60,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -60,6 +60,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -60,6 +60,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -58,6 +58,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -61,6 +61,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -68,6 +68,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.conf.SettingsTools.renderLocale;
|
||||
import static org.jooq.impl.CommonTableExpressionList.markTopLevelCteAndAccept;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
|
||||
@ -39,12 +39,6 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static java.lang.Math.ceil;
|
||||
import static java.lang.Math.log;
|
||||
import static java.lang.Math.max;
|
||||
import static java.lang.Math.min;
|
||||
import static java.lang.Math.pow;
|
||||
import static java.lang.Math.round;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
@ -73,6 +67,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
import static org.jooq.conf.ParamType.INDEXED;
|
||||
import static org.jooq.impl.DSL.falseCondition;
|
||||
|
||||
@ -120,6 +120,10 @@ implements
|
||||
break;
|
||||
|
||||
|
||||
ctx.visit(N_ARBITRARY);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -68,6 +68,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
import static org.jooq.impl.Keywords.K_AND;
|
||||
@ -79,20 +80,18 @@ import static org.jooq.impl.Tools.nullSafe;
|
||||
import static org.jooq.impl.Tools.nullableIf;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.jooq.BetweenAndStep;
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Function1;
|
||||
import org.jooq.Function3;
|
||||
import org.jooq.QueryPart;
|
||||
// ...
|
||||
import org.jooq.RowN;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.QOM.Between;
|
||||
import org.jooq.QueryPart;
|
||||
// ...
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
|
||||
@ -113,6 +113,9 @@ implements
|
||||
case FIREBIRD:
|
||||
return true;
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -148,6 +151,10 @@ implements
|
||||
ctx.visit(function(N_BIN_AND, getDataType(), arg1, arg2));
|
||||
break;
|
||||
|
||||
|
||||
ctx.visit(function(N_BITWISE_AND, getDataType(), arg1, arg2));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.sql('(');
|
||||
Expression.<Field<T>, BitAnd<T>>acceptAssociative(
|
||||
|
||||
@ -294,6 +294,10 @@ implements
|
||||
ctx.visit(N_BIT_AND_AGG);
|
||||
break;
|
||||
|
||||
|
||||
ctx.visit(N_BITWISE_AND_AGG);
|
||||
break;
|
||||
|
||||
default:
|
||||
super.acceptFunctionName(ctx);
|
||||
break;
|
||||
|
||||
@ -131,6 +131,7 @@ implements
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
case YUGABYTEDB:
|
||||
return false;
|
||||
|
||||
@ -192,6 +193,7 @@ implements
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
case YUGABYTEDB:
|
||||
ctx.visit(value.bitAnd((Field) one().shl(bit)).shr(bit));
|
||||
break;
|
||||
|
||||
@ -116,6 +116,7 @@ implements
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
@ -160,6 +161,7 @@ implements
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
|
||||
ctx.visit(imul(inline(8), function(N_LENGTH, getDataType(), string)));
|
||||
break;
|
||||
|
||||
|
||||
@ -113,6 +113,9 @@ implements
|
||||
case FIREBIRD:
|
||||
return true;
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -152,6 +155,10 @@ implements
|
||||
ctx.visit(function(N_BIN_NOT, getDataType(), arg1));
|
||||
break;
|
||||
|
||||
|
||||
ctx.visit(function(N_BITWISE_NOT, getDataType(), arg1));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (arg1 instanceof AbstractField && ((AbstractField<?>) arg1).parenthesised(ctx))
|
||||
ctx.sql('~').visit(arg1);
|
||||
|
||||
@ -113,6 +113,9 @@ implements
|
||||
return true;
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -152,6 +155,10 @@ implements
|
||||
break;
|
||||
|
||||
|
||||
ctx.visit(function(N_BITWISE_OR, getDataType(), arg1, arg2));
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -294,6 +294,10 @@ implements
|
||||
ctx.visit(N_BIT_OR_AGG);
|
||||
break;
|
||||
|
||||
|
||||
ctx.visit(N_BITWISE_OR_AGG);
|
||||
break;
|
||||
|
||||
default:
|
||||
super.acceptFunctionName(ctx);
|
||||
break;
|
||||
|
||||
@ -146,6 +146,7 @@ implements
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
case YUGABYTEDB:
|
||||
return false;
|
||||
|
||||
@ -219,6 +220,7 @@ implements
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
case YUGABYTEDB: {
|
||||
if (newValue == null)
|
||||
ctx.visit(value.bitOr((Field) one().shl(bit)));
|
||||
|
||||
@ -120,6 +120,7 @@ implements
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
case YUGABYTEDB:
|
||||
return false;
|
||||
|
||||
@ -165,6 +166,7 @@ implements
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
case YUGABYTEDB:
|
||||
ctx.visit(DSL.bitNot(DSL.bitXor((Field<Number>) arg1, (Field<Number>) arg2)));
|
||||
break;
|
||||
|
||||
@ -113,6 +113,9 @@ implements
|
||||
return true;
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
case SQLITE:
|
||||
return false;
|
||||
|
||||
@ -151,6 +154,10 @@ implements
|
||||
break;
|
||||
|
||||
|
||||
ctx.visit(function(N_BITWISE_XOR, getDataType(), arg1, arg2));
|
||||
break;
|
||||
|
||||
|
||||
case SQLITE:
|
||||
ctx.visit(// ~(a & b) & (a | b)
|
||||
DSL.bitAnd(
|
||||
|
||||
@ -120,6 +120,7 @@ implements
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
|
||||
ctx.visit(function(N_LENGTH, getDataType(), string));
|
||||
break;
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ import static org.jooq.SQLDialect.IGNITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.ConstraintImpl.Action.CASCADE;
|
||||
import static org.jooq.impl.ConstraintImpl.Action.NO_ACTION;
|
||||
import static org.jooq.impl.ConstraintImpl.Action.RESTRICT;
|
||||
@ -112,8 +113,6 @@ import org.jooq.SQLDialect;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.impl.QOM.UNotYetImplemented;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
|
||||
@ -100,6 +100,7 @@ implements
|
||||
|
||||
|
||||
case SQLITE:
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
@ -123,6 +124,7 @@ implements
|
||||
|
||||
|
||||
case SQLITE:
|
||||
|
||||
ctx.visit(idiv(DSL.cos(value), DSL.sin(value)));
|
||||
break;
|
||||
|
||||
|
||||
@ -123,6 +123,7 @@ implements
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
case YUGABYTEDB:
|
||||
return false;
|
||||
|
||||
@ -170,6 +171,7 @@ implements
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
case YUGABYTEDB:
|
||||
ctx.visit(idiv(
|
||||
iadd(DSL.exp(imul(value, two())), one()),
|
||||
|
||||
@ -101,6 +101,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.impl.Names.N_COUNT;
|
||||
@ -116,11 +117,11 @@ import static org.jooq.impl.Names.N_SYSTEM_TIME;
|
||||
import static org.jooq.impl.Names.N_VALUE;
|
||||
import static org.jooq.impl.SQLDataType.BOOLEAN;
|
||||
import static org.jooq.impl.SQLDataType.DATE;
|
||||
import static org.jooq.impl.SQLDataType.INTEGER;
|
||||
import static org.jooq.impl.SQLDataType.JSON;
|
||||
import static org.jooq.impl.SQLDataType.JSONB;
|
||||
import static org.jooq.impl.SQLDataType.TIME;
|
||||
import static org.jooq.impl.SQLDataType.TIMESTAMP;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.combine;
|
||||
import static org.jooq.impl.Tools.configuration;
|
||||
@ -26279,7 +26280,7 @@ public class DSL {
|
||||
@NotNull
|
||||
@Support({ MYSQL, POSTGRES })
|
||||
public static Field<Integer> grouping(Field<?> field) {
|
||||
return function("grouping", Integer.class, field);
|
||||
return function("grouping", INTEGER, field);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@ -59,6 +59,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.Names.N_DECODE;
|
||||
|
||||
@ -808,6 +808,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
|
||||
case POSTGRES:
|
||||
|
||||
case YUGABYTEDB:
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -138,6 +138,7 @@ final class Dual extends AbstractTable<Record> implements QOM.Dual {
|
||||
case H2:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
case YUGABYTEDB:
|
||||
break;
|
||||
|
||||
|
||||
@ -190,6 +190,7 @@ final class FieldMapsForInsert extends AbstractQueryPart implements UNotYetImple
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MARIADB: {
|
||||
@ -353,11 +354,14 @@ final class FieldMapsForInsert extends AbstractQueryPart implements UNotYetImple
|
||||
|
||||
|
||||
|
||||
// See https://github.com/trinodb/trino/issues/10161
|
||||
|
||||
for (List<Field<?>> row : values.values())
|
||||
for (Field<?> value : row)
|
||||
if (value instanceof ScalarSubquery)
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
// [#14742] MariaDB can't have (unaliased!) self-references of the INSERT
|
||||
// target table in INSERT INTO t VALUES ((SELECT .. FROM t)),
|
||||
|
||||
@ -37,18 +37,21 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.Names.N_GROUP_CONCAT;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jooq.AggregateFunction;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.GroupConcatOrderByStep;
|
||||
import org.jooq.OrderField;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.QOM.UNotYetImplemented;
|
||||
|
||||
/**
|
||||
@ -61,6 +64,8 @@ implements
|
||||
GroupConcatOrderByStep,
|
||||
UNotYetImplemented {
|
||||
|
||||
final Set<SQLDialect> REQUIRE_WITHIN_GROUP = SQLDialect.supportedBy();
|
||||
|
||||
private final Field<?> field;
|
||||
private final SortFieldList orderBy;
|
||||
private String separator;
|
||||
@ -88,10 +93,9 @@ implements
|
||||
if (!orderBy.isEmpty())
|
||||
result.withinGroupOrderBy(orderBy);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// [#3045] [#11485] Dialects with mandatory WITHIN GROUP clause
|
||||
else if (REQUIRE_WITHIN_GROUP.contains(ctx.dialect()))
|
||||
result.withinGroupOrderBy(orderBy);
|
||||
|
||||
ctx.visit(fo(result));
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
import static org.jooq.impl.DSL.emptyGroupingSet;
|
||||
|
||||
|
||||
@ -212,8 +212,10 @@ implements
|
||||
JSONReturning jsonReturning;
|
||||
|
||||
// Workaround for https://github.com/h2database/h2database/issues/2496
|
||||
if (ctx.family() == H2 && fields.isEmpty())
|
||||
if (fields.isEmpty() && ctx.family() == H2)
|
||||
jsonNull = new JSONNull(JSONOnNull.NULL_ON_NULL);
|
||||
else if (fields.isEmpty() && JSONNull.NO_SUPPORT_NULL_ON_EMPTY.contains(ctx.dialect()))
|
||||
jsonNull = new JSONNull(null);
|
||||
else
|
||||
jsonNull = new JSONNull(onNull);
|
||||
|
||||
|
||||
@ -48,13 +48,16 @@ import static org.jooq.impl.DSL.groupConcatDistinct;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.JSONEntryImpl.jsonCastMapper;
|
||||
import static org.jooq.impl.JSONEntryImpl.jsonMerge;
|
||||
import static org.jooq.impl.Keywords.K_AS;
|
||||
import static org.jooq.impl.Keywords.K_DISTINCT;
|
||||
import static org.jooq.impl.Names.N_ARRAY_AGG;
|
||||
import static org.jooq.impl.Names.N_CAST;
|
||||
import static org.jooq.impl.Names.N_GROUP_CONCAT;
|
||||
import static org.jooq.impl.Names.N_JSONB_AGG;
|
||||
import static org.jooq.impl.Names.N_JSON_AGG;
|
||||
import static org.jooq.impl.Names.N_JSON_ARRAYAGG;
|
||||
import static org.jooq.impl.Names.N_JSON_GROUP_ARRAY;
|
||||
import static org.jooq.impl.Names.N_JSON_PARSE;
|
||||
import static org.jooq.impl.Names.N_JSON_QUOTE;
|
||||
import static org.jooq.impl.QOM.JSONOnNull.ABSENT_ON_NULL;
|
||||
import static org.jooq.impl.QOM.JSONOnNull.NULL_ON_NULL;
|
||||
@ -179,6 +182,33 @@ implements
|
||||
acceptOverClause(ctx);
|
||||
break;
|
||||
|
||||
|
||||
ctx.visit(N_CAST).sql('(');
|
||||
ctx.visit(N_ARRAY_AGG).sql('(');
|
||||
acceptDistinct(ctx);
|
||||
|
||||
if (arguments.get(0).getDataType().isJSON())
|
||||
ctx.visit(function(N_JSON_PARSE, JSON, arguments.get(0)));
|
||||
|
||||
// [#11485] CHAR types can't be cast to JSON: https://trino.io/docs/current/functions/json.html#cast-to-json
|
||||
else if (arguments.get(0).getDataType().getSQLDataType() == SQLDataType.CHAR)
|
||||
ctx.visit(arguments.get(0).cast(VARCHAR));
|
||||
else
|
||||
ctx.visit(arguments.get(0));
|
||||
|
||||
acceptOrderBy(ctx);
|
||||
ctx.sql(')');
|
||||
|
||||
if (onNull == ABSENT_ON_NULL)
|
||||
acceptFilterClause(ctx, f(arguments.get(0).isNotNull()));
|
||||
else
|
||||
acceptFilterClause(ctx);
|
||||
|
||||
acceptOverClause(ctx);
|
||||
ctx.sql(' ').visit(K_AS).sql(' ').visit(JSON);
|
||||
ctx.sql(')');
|
||||
break;
|
||||
|
||||
default:
|
||||
acceptStandard(ctx);
|
||||
break;
|
||||
|
||||
@ -112,6 +112,7 @@ implements
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
@ -161,6 +162,7 @@ implements
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSONB, field, inline("$.").concat(attribute)));
|
||||
break;
|
||||
|
||||
|
||||
@ -112,6 +112,7 @@ implements
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
@ -156,6 +157,7 @@ implements
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSONB, field, inline("$[").concat(index).concat(inline("]"))));
|
||||
break;
|
||||
|
||||
|
||||
@ -111,6 +111,9 @@ implements
|
||||
case SQLITE:
|
||||
return false;
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -152,6 +155,10 @@ implements
|
||||
ctx.visit(DSL.field(select(jsonbArrayAgg(DSL.field(name("key")))).from("json_each({0})", field)));
|
||||
break;
|
||||
|
||||
|
||||
ctx.visit(DSL.cast(function(N_MAP_KEYS, OTHER, DSL.field("cast(json_parse({0}) as map(varchar, json))", OTHER, field)), JSON));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.visit(function(N_JSON_KEYS, JSONB, field));
|
||||
break;
|
||||
|
||||
@ -176,6 +176,10 @@ final class JSONEntryImpl<T> extends AbstractQueryPart implements JSONEntry<T>,
|
||||
ctx.visit(key).sql(", ").visit(jsonCast(ctx, value));
|
||||
break;
|
||||
|
||||
|
||||
ctx.visit(K_KEY).sql(' ').visit(jsonCast(ctx, key)).sql(' ').visit(K_VALUE).sql(' ').visit(jsonCast(ctx, value));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.visit(K_KEY).sql(' ').visit(key).sql(' ').visit(K_VALUE).sql(' ').visit(jsonCast(ctx, value));
|
||||
break;
|
||||
@ -291,6 +295,14 @@ final class JSONEntryImpl<T> extends AbstractQueryPart implements JSONEntry<T>,
|
||||
return field.cast(VARCHAR);
|
||||
else
|
||||
return field;
|
||||
|
||||
|
||||
|
||||
// [#11485] https://github.com/trinodb/trino/issues/16489
|
||||
if (field instanceof Param)
|
||||
return inlined(field);
|
||||
else
|
||||
return field;
|
||||
}
|
||||
|
||||
return field;
|
||||
|
||||
@ -112,6 +112,7 @@ implements
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
@ -161,6 +162,7 @@ implements
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSON, field, inline("$.").concat(attribute)));
|
||||
break;
|
||||
|
||||
|
||||
@ -112,6 +112,7 @@ implements
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
@ -156,6 +157,7 @@ implements
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
|
||||
ctx.visit(function(N_JSON_EXTRACT, JSON, field, inline("$[").concat(index).concat(inline("]"))));
|
||||
break;
|
||||
|
||||
|
||||
@ -109,6 +109,9 @@ implements
|
||||
case SQLITE:
|
||||
return false;
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
@ -146,6 +149,10 @@ implements
|
||||
ctx.visit(DSL.field(select(jsonArrayAgg(DSL.field(name("key")))).from("json_each({0})", field)));
|
||||
break;
|
||||
|
||||
|
||||
ctx.visit(DSL.cast(function(N_MAP_KEYS, OTHER, DSL.field("cast(json_parse({0}) as map(varchar, json))", OTHER, field)), JSON));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.visit(function(N_JSON_KEYS, getDataType(), field));
|
||||
break;
|
||||
|
||||
@ -39,12 +39,14 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.impl.QOM.JSONOnNull.ABSENT_ON_NULL;
|
||||
import static org.jooq.impl.QOM.JSONOnNull.NULL_ON_NULL;
|
||||
// ...
|
||||
import static org.jooq.impl.Keywords.K_ABSENT;
|
||||
import static org.jooq.impl.Keywords.K_NULL;
|
||||
import static org.jooq.impl.Keywords.K_ON;
|
||||
import static org.jooq.impl.QOM.JSONOnNull.ABSENT_ON_NULL;
|
||||
import static org.jooq.impl.QOM.JSONOnNull.NULL_ON_NULL;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ -58,6 +60,7 @@ import org.jooq.impl.QOM.UTransient;
|
||||
*/
|
||||
final class JSONNull extends AbstractQueryPart implements SimpleQueryPart, UTransient {
|
||||
static final Set<SQLDialect> NO_SUPPORT_ABSENT_ON_NULL = SQLDialect.supportedBy(MARIADB, MYSQL, SQLITE);
|
||||
static final Set<SQLDialect> NO_SUPPORT_NULL_ON_EMPTY = SQLDialect.supportedBy();
|
||||
|
||||
final JSONOnNull type;
|
||||
|
||||
|
||||
@ -265,10 +265,10 @@ implements
|
||||
if (entries.isEmpty() && ctx.family() == H2)
|
||||
jsonNull = new JSONNull(JSONOnNull.NULL_ON_NULL);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Some dialects support the JSONNull clause only for non-empty JSON_OBJECT
|
||||
// E.g. https://trino.io/docs/current/functions/json.html#json-object
|
||||
else if (entries.isEmpty() && JSONNull.NO_SUPPORT_NULL_ON_EMPTY.contains(ctx.dialect()))
|
||||
jsonNull = new JSONNull(null);
|
||||
else
|
||||
jsonNull = new JSONNull(onNull);
|
||||
|
||||
|
||||
@ -38,16 +38,22 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.DSL.groupConcat;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.jsonObject;
|
||||
import static org.jooq.impl.DSL.noCondition;
|
||||
import static org.jooq.impl.DSL.when;
|
||||
import static org.jooq.impl.Keywords.K_AS;
|
||||
import static org.jooq.impl.Names.N_ARRAY_AGG;
|
||||
import static org.jooq.impl.Names.N_CAST;
|
||||
import static org.jooq.impl.Names.N_FIELD;
|
||||
import static org.jooq.impl.Names.N_JSONB_OBJECT_AGG;
|
||||
import static org.jooq.impl.Names.N_JSON_GROUP_OBJECT;
|
||||
import static org.jooq.impl.Names.N_JSON_OBJECTAGG;
|
||||
import static org.jooq.impl.Names.N_JSON_OBJECT_AGG;
|
||||
import static org.jooq.impl.Names.N_JSON_PARSE;
|
||||
import static org.jooq.impl.Names.N_MAP;
|
||||
import static org.jooq.impl.Names.N_OBJECT_AGG;
|
||||
import static org.jooq.impl.QOM.JSONOnNull.ABSENT_ON_NULL;
|
||||
import static org.jooq.impl.QOM.JSONOnNull.NULL_ON_NULL;
|
||||
@ -135,12 +141,49 @@ implements
|
||||
acceptSQLite(ctx);
|
||||
break;
|
||||
|
||||
|
||||
acceptTrino(ctx);
|
||||
break;
|
||||
|
||||
default:
|
||||
acceptStandard(ctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private final void acceptTrino(Context<?> ctx) {
|
||||
ctx.visit(N_CAST).sql('(');
|
||||
ctx.visit(N_MAP).sql('(');
|
||||
acceptTrinoArrayAgg(ctx, entry.key(), entry.value());
|
||||
ctx.sql(", ");
|
||||
acceptTrinoArrayAgg(ctx, entry.value(), entry.value());
|
||||
ctx.sql(") ");
|
||||
ctx.visit(K_AS).sql(' ').visit(JSON);
|
||||
ctx.sql(')');
|
||||
}
|
||||
|
||||
private final void acceptTrinoArrayAgg(Context<?> ctx, Field<?> f1, Field<?> f2) {
|
||||
ctx.visit(N_ARRAY_AGG).sql('(');
|
||||
|
||||
if (f1.getDataType().isJSON())
|
||||
ctx.visit(function(N_JSON_PARSE, JSON, f1));
|
||||
|
||||
// [#11485] CHAR types can't be cast to JSON: https://trino.io/docs/current/functions/json.html#cast-to-json
|
||||
else if (f1.getDataType().getSQLDataType() == SQLDataType.CHAR)
|
||||
ctx.visit(f1.cast(VARCHAR));
|
||||
else
|
||||
ctx.visit(f1);
|
||||
|
||||
ctx.sql(")");
|
||||
|
||||
if (onNull == ABSENT_ON_NULL)
|
||||
acceptFilterClause(ctx, f(f2.isNotNull()));
|
||||
else
|
||||
acceptFilterClause(ctx);
|
||||
|
||||
acceptOverClause(ctx);
|
||||
}
|
||||
|
||||
private final void acceptPostgres(Context<?> ctx) {
|
||||
ctx.visit(getDataType() == JSON ? N_JSON_OBJECT_AGG : N_JSONB_OBJECT_AGG).sql('(');
|
||||
ctx.visit(entry);
|
||||
|
||||
@ -93,6 +93,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
import static org.jooq.impl.DSL.condition;
|
||||
import static org.jooq.impl.DSL.exists;
|
||||
|
||||
@ -98,6 +98,7 @@ implements
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
@ -117,6 +118,7 @@ implements
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
|
||||
ctx.visit(DSL.substring(string, inline(1), length));
|
||||
break;
|
||||
|
||||
|
||||
@ -184,7 +184,8 @@ final class Limit extends AbstractQueryPart implements UTransient {
|
||||
}
|
||||
|
||||
|
||||
case DERBY: {
|
||||
case DERBY:
|
||||
{
|
||||
acceptStandard(ctx, castMode);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -67,23 +67,23 @@ final class Names {
|
||||
static final Name N_ADD_SECONDS = systemName("add_seconds");
|
||||
static final Name N_ADD_YEARS = systemName("add_years");
|
||||
static final Name N_ANY = systemName("any");
|
||||
static final Name N_ARBITRARY = systemName("arbitrary");
|
||||
static final Name N_ARRAY = systemName("array");
|
||||
static final Name N_ARRAY_AGG = systemName("array_agg");
|
||||
static final Name N_ARRAY_CONSTRUCT = systemName("array_construct");
|
||||
static final Name N_ARRAY_CONSTRUCT_COMPACT = systemName("array_construct_compact");
|
||||
static final Name N_ARRAY_LENGTH = systemName("array_length");
|
||||
static final Name N_BITCOUNT = systemName("bitcount");
|
||||
static final Name N_BITXNOR = systemName("bitxnor");
|
||||
static final Name N_BITWISE_AND_AGG = systemName("bitwise_and_agg");
|
||||
static final Name N_BITWISE_OR_AGG = systemName("bitwise_or_agg");
|
||||
static final Name N_BIT_NAND = systemName("bit_nand");
|
||||
static final Name N_BIT_NOR = systemName("bit_nor");
|
||||
static final Name N_BIT_XNOR = systemName("bit_xnor");
|
||||
static final Name N_BOOLAND_AGG = systemName("booland_agg");
|
||||
static final Name N_BOOLOR_AGG = systemName("boolor_agg");
|
||||
static final Name N_BYTEA = systemName("bytea");
|
||||
static final Name N_BYTE_LENGTH = systemName("byte_length");
|
||||
static final Name N_CAST = systemName("cast");
|
||||
static final Name N_CHARINDEX = systemName("charindex");
|
||||
static final Name N_CHECK_JSON = systemName("check_json");
|
||||
static final Name N_CHOOSE = systemName("choose");
|
||||
static final Name N_COLLECT = systemName("collect");
|
||||
static final Name N_CONCAT = systemName("concat");
|
||||
@ -100,7 +100,6 @@ final class Names {
|
||||
static final Name N_CURRENT_TIME = systemName("current_time");
|
||||
static final Name N_CURRENT_TIMESTAMP = systemName("current_timestamp");
|
||||
static final Name N_CURRVAL = systemName("currval");
|
||||
static final Name N_DATALENGTH = systemName("datalength");
|
||||
static final Name N_DATEADD = systemName("dateadd");
|
||||
static final Name N_DATEDIFF = systemName("datediff");
|
||||
static final Name N_DATEPART = systemName("datepart");
|
||||
@ -124,7 +123,6 @@ final class Names {
|
||||
static final Name N_EXTRACT = systemName("extract");
|
||||
static final Name N_FIRST_VALUE = systemName("first_value");
|
||||
static final Name N_FLASHBACK = systemName("flashback");
|
||||
static final Name N_FORMAT = systemName("format");
|
||||
static final Name N_FUNCTION = systemName("function");
|
||||
static final Name N_GENERATE_ARRAY = systemName("generate_array");
|
||||
static final Name N_GENERATE_SERIES = systemName("generate_series");
|
||||
@ -144,8 +142,6 @@ final class Names {
|
||||
static final Name N_IIF = systemName("iif");
|
||||
static final Name N_INSERT = systemName("insert");
|
||||
static final Name N_INSERTED = systemName("inserted");
|
||||
static final Name N_INSTR = systemName("instr");
|
||||
static final Name N_ISJSON = systemName("isjson");
|
||||
static final Name N_JOIN = systemName("join");
|
||||
static final Name N_JSON = systemName("json");
|
||||
static final Name N_JSONB_AGG = systemName("jsonb_agg");
|
||||
@ -159,18 +155,16 @@ final class Names {
|
||||
static final Name N_JSON_ARRAYAGG = systemName("json_arrayagg");
|
||||
static final Name N_JSON_BUILD_ARRAY = systemName("json_build_array");
|
||||
static final Name N_JSON_CONTAINS_PATH = systemName("json_contains_path");
|
||||
static final Name N_JSON_EXTRACT = systemName("json_extract");
|
||||
static final Name N_JSON_GROUP_ARRAY = systemName("json_group_array");
|
||||
static final Name N_JSON_GROUP_OBJECT = systemName("json_group_object");
|
||||
static final Name N_JSON_MERGE = systemName("json_merge");
|
||||
static final Name N_JSON_MERGE_PRESERVE = systemName("json_merge_preserve");
|
||||
static final Name N_JSON_MODIFY = systemName("json_modify");
|
||||
static final Name N_JSON_OBJECTAGG = systemName("json_objectagg");
|
||||
static final Name N_JSON_OBJECT_AGG = systemName("json_object_agg");
|
||||
static final Name N_JSON_PARSE = systemName("json_parse");
|
||||
static final Name N_JSON_QUERY = systemName("json_query");
|
||||
static final Name N_JSON_QUOTE = systemName("json_quote");
|
||||
static final Name N_JSON_TABLE = systemName("json_table");
|
||||
static final Name N_JSON_TRANSFORM = systemName("json_transform");
|
||||
static final Name N_JSON_TYPE = systemName("json_type");
|
||||
static final Name N_JSON_UNQUOTE = systemName("json_unquote");
|
||||
static final Name N_JSON_VALUE = systemName("json_value");
|
||||
@ -218,7 +212,6 @@ final class Names {
|
||||
static final Name N_PLPGSQL = systemName("plpgsql");
|
||||
static final Name N_PLUS = systemName("plus");
|
||||
static final Name N_POWER = systemName("power");
|
||||
static final Name N_PRINTF = systemName("printf");
|
||||
static final Name N_RANDOMBLOB = systemName("randomblob");
|
||||
static final Name N_RANK = systemName("rank");
|
||||
static final Name N_RATIO_TO_REPORT = systemName("ratio_to_report");
|
||||
@ -261,7 +254,6 @@ final class Names {
|
||||
static final Name N_STRFTIME = systemName("strftime");
|
||||
static final Name N_STRING_AGG = systemName("string_agg");
|
||||
static final Name N_STRING_SPLIT = systemName("string_split");
|
||||
static final Name N_STRTOK = systemName("strtok");
|
||||
static final Name N_STR_REPLACE = systemName("str_replace");
|
||||
static final Name N_ST_NUMINTERIORRINGS = systemName("st_numinteriorrings");
|
||||
static final Name N_SUB = systemName("sub");
|
||||
@ -341,6 +333,13 @@ final class Names {
|
||||
static final Name N_BITOR = systemName("bitor");
|
||||
static final Name N_BITSHIFTLEFT = systemName("bitshiftleft");
|
||||
static final Name N_BITSHIFTRIGHT = systemName("bitshiftright");
|
||||
static final Name N_BITWISE_AND = systemName("bitwise_and");
|
||||
static final Name N_BITWISE_LEFT_SHIFT = systemName("bitwise_left_shift");
|
||||
static final Name N_BITWISE_NOT = systemName("bitwise_not");
|
||||
static final Name N_BITWISE_OR = systemName("bitwise_or");
|
||||
static final Name N_BITWISE_RIGHT_SHIFT = systemName("bitwise_right_shift");
|
||||
static final Name N_BITWISE_XOR = systemName("bitwise_xor");
|
||||
static final Name N_BITXNOR = systemName("bitxnor");
|
||||
static final Name N_BITXOR = systemName("bitxor");
|
||||
static final Name N_BIT_AND = systemName("bit_and");
|
||||
static final Name N_BIT_AND_AGG = systemName("bit_and_agg");
|
||||
@ -361,11 +360,13 @@ final class Names {
|
||||
static final Name N_BIT_XOR_AGG = systemName("bit_xor_agg");
|
||||
static final Name N_BOOL_AND = systemName("bool_and");
|
||||
static final Name N_BOOL_OR = systemName("bool_or");
|
||||
static final Name N_BYTE_LENGTH = systemName("byte_length");
|
||||
static final Name N_CARDINALITY = systemName("cardinality");
|
||||
static final Name N_CEIL = systemName("ceil");
|
||||
static final Name N_CEILING = systemName("ceiling");
|
||||
static final Name N_CHAR = systemName("char");
|
||||
static final Name N_CHAR_LENGTH = systemName("char_length");
|
||||
static final Name N_CHECK_JSON = systemName("check_json");
|
||||
static final Name N_CHR = systemName("chr");
|
||||
static final Name N_COALESCE = systemName("coalesce");
|
||||
static final Name N_CONDITION = systemName("condition");
|
||||
@ -383,6 +384,7 @@ final class Names {
|
||||
static final Name N_CURRENT_CATALOG = systemName("current_catalog");
|
||||
static final Name N_CURRENT_SCHEMA = systemName("current_schema");
|
||||
static final Name N_CURRENT_USER = systemName("current_user");
|
||||
static final Name N_DATALENGTH = systemName("datalength");
|
||||
static final Name N_DATE_ADD = systemName("date_add");
|
||||
static final Name N_DEGREES = systemName("degrees");
|
||||
static final Name N_DELETING = systemName("deleting");
|
||||
@ -394,6 +396,7 @@ final class Names {
|
||||
static final Name N_EXP = systemName("exp");
|
||||
static final Name N_FIELD = systemName("field");
|
||||
static final Name N_FLOOR = systemName("floor");
|
||||
static final Name N_FORMAT = systemName("format");
|
||||
static final Name N_GENERATE_UUID = systemName("generate_uuid");
|
||||
static final Name N_GENGUID = systemName("genguid");
|
||||
static final Name N_GEN_RANDOM_UUID = systemName("gen_random_uuid");
|
||||
@ -404,6 +407,8 @@ final class Names {
|
||||
static final Name N_HEX = systemName("hex");
|
||||
static final Name N_IFNULL = systemName("ifnull");
|
||||
static final Name N_INSERTING = systemName("inserting");
|
||||
static final Name N_INSTR = systemName("instr");
|
||||
static final Name N_ISJSON = systemName("isjson");
|
||||
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");
|
||||
@ -416,16 +421,19 @@ final class Names {
|
||||
static final Name N_JSONB_REPLACE = systemName("jsonb_replace");
|
||||
static final Name N_JSONB_SET = systemName("jsonb_set");
|
||||
static final Name N_JSON_ARRAY = systemName("json_array");
|
||||
static final Name N_JSON_EXTRACT = systemName("json_extract");
|
||||
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_INSERT = systemName("json_insert");
|
||||
static final Name N_JSON_KEYS = systemName("json_keys");
|
||||
static final Name N_JSON_MODIFY = systemName("json_modify");
|
||||
static final Name N_JSON_OBJECT = systemName("json_object");
|
||||
static final Name N_JSON_REMOVE = systemName("json_remove");
|
||||
static final Name N_JSON_REPLACE = systemName("json_replace");
|
||||
static final Name N_JSON_SET = systemName("json_set");
|
||||
static final Name N_JSON_TRANSFORM = systemName("json_transform");
|
||||
static final Name N_JSON_VALID = systemName("json_valid");
|
||||
static final Name N_LCASE = systemName("lcase");
|
||||
static final Name N_LEFT = systemName("left");
|
||||
@ -443,6 +451,7 @@ final class Names {
|
||||
static final Name N_LPAD = systemName("lpad");
|
||||
static final Name N_LSHIFT = systemName("lshift");
|
||||
static final Name N_LTRIM = systemName("ltrim");
|
||||
static final Name N_MAP_KEYS = systemName("map_keys");
|
||||
static final Name N_MAX = systemName("max");
|
||||
static final Name N_MD5 = systemName("md5");
|
||||
static final Name N_MEDIAN = systemName("median");
|
||||
@ -456,6 +465,7 @@ final class Names {
|
||||
static final Name N_OVERLAY = systemName("overlay");
|
||||
static final Name N_PI = systemName("pi");
|
||||
static final Name N_POSITION = systemName("position");
|
||||
static final Name N_PRINTF = systemName("printf");
|
||||
static final Name N_PRIOR = systemName("prior");
|
||||
static final Name N_PRODUCT = systemName("product");
|
||||
static final Name N_RADIANS = systemName("radians");
|
||||
@ -496,9 +506,11 @@ final class Names {
|
||||
static final Name N_SQR = systemName("sqr");
|
||||
static final Name N_SQRT = systemName("sqrt");
|
||||
static final Name N_SQUARE = systemName("square");
|
||||
static final Name N_STARTS_WITH = systemName("starts_with");
|
||||
static final Name N_STDDEV_POP = systemName("stddev_pop");
|
||||
static final Name N_STDDEV_SAMP = systemName("stddev_samp");
|
||||
static final Name N_STRREVERSE = systemName("strreverse");
|
||||
static final Name N_STRTOK = systemName("strtok");
|
||||
static final Name N_ST_AREA = systemName("st_area");
|
||||
static final Name N_ST_ASBINARY = systemName("st_asbinary");
|
||||
static final Name N_ST_ASTEXT = systemName("st_astext");
|
||||
@ -542,6 +554,7 @@ final class Names {
|
||||
static final Name N_TANH = systemName("tanh");
|
||||
static final Name N_TAU = systemName("tau");
|
||||
static final Name N_TIMESTAMP_ADD = systemName("timestamp_add");
|
||||
static final Name N_TO_BASE = systemName("to_base");
|
||||
static final Name N_TO_CHAR = systemName("to_char");
|
||||
static final Name N_TO_DATE = systemName("to_date");
|
||||
static final Name N_TO_HEX = systemName("to_hex");
|
||||
|
||||
@ -122,6 +122,7 @@ implements
|
||||
case FIREBIRD:
|
||||
case IGNITE:
|
||||
case POSTGRES:
|
||||
|
||||
case YUGABYTEDB:
|
||||
return true;
|
||||
|
||||
@ -185,6 +186,7 @@ implements
|
||||
case FIREBIRD:
|
||||
case IGNITE:
|
||||
case POSTGRES:
|
||||
|
||||
case YUGABYTEDB:
|
||||
ctx.visit(function(N_COALESCE, getDataType(), value, defaultValue));
|
||||
break;
|
||||
|
||||
@ -97,6 +97,7 @@ final class Nvl2<T> extends AbstractField<T> implements QOM.Nvl2<T> {
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
case YUGABYTEDB:
|
||||
acceptCase(ctx);
|
||||
break;
|
||||
|
||||
@ -122,6 +122,7 @@ implements
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
|
||||
ctx.visit(function(N_LENGTH, getDataType(), string));
|
||||
break;
|
||||
|
||||
|
||||
@ -9449,9 +9449,11 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
return null;
|
||||
|
||||
if (parseKeywordIf("BIT_AND") ||
|
||||
parseKeywordIf("BITWISE_AND") ||
|
||||
parseKeywordIf("BITAND") ||
|
||||
parseKeywordIf("BIN_AND") ||
|
||||
(agg = parseKeywordIf("BIT_AND_AGG")) ||
|
||||
(agg = parseKeywordIf("BITWISE_AND_AGG")) ||
|
||||
(agg = parseKeywordIf("BITAND_AGG")) ||
|
||||
(agg = parseKeywordIf("BIN_AND_AGG"))) {
|
||||
parse('(');
|
||||
@ -9489,9 +9491,11 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
return bitNand((Field) x, (Field) y);
|
||||
}
|
||||
else if (parseKeywordIf("BIT_OR") ||
|
||||
parseKeywordIf("BITWISE_OR") ||
|
||||
parseKeywordIf("BITOR") ||
|
||||
parseKeywordIf("BIN_OR") ||
|
||||
(agg = parseKeywordIf("BIT_OR_AGG")) ||
|
||||
(agg = parseKeywordIf("BITWISE_OR_AGG")) ||
|
||||
(agg = parseKeywordIf("BITOR_AGG")) ||
|
||||
(agg = parseKeywordIf("BIN_OR_AGG"))) {
|
||||
parse('(');
|
||||
@ -9529,6 +9533,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
return bitNor((Field) x, (Field) y);
|
||||
}
|
||||
else if (parseKeywordIf("BIT_XOR") ||
|
||||
parseKeywordIf("BITWISE_XOR") ||
|
||||
parseKeywordIf("BITXOR") ||
|
||||
parseKeywordIf("BIN_XOR") ||
|
||||
(agg = parseKeywordIf("BIT_XOR_AGG")) ||
|
||||
@ -9564,14 +9569,14 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
|
||||
return bitXNor((Field) x, (Field) y);
|
||||
}
|
||||
else if (parseKeywordIf("BIT_NOT", "BITNOT", "BIN_NOT")) {
|
||||
else if (parseKeywordIf("BIT_NOT", "BITNOT", "BIN_NOT", "BITWISE_NOT")) {
|
||||
parse('(');
|
||||
Field<?> x = toField(parseNumericOp());
|
||||
parse(')');
|
||||
|
||||
return bitNot((Field) x);
|
||||
}
|
||||
else if (parseKeywordIf("BIN_SHL", "BITSHIFTLEFT")) {
|
||||
else if (parseKeywordIf("BIN_SHL", "BITSHIFTLEFT", "BITWISE_LEFT_SHIFT")) {
|
||||
parse('(');
|
||||
Field<?> x = toField(parseNumericOp());
|
||||
parse(',');
|
||||
@ -9580,7 +9585,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
|
||||
return shl((Field) x, (Field) y);
|
||||
}
|
||||
else if (parseKeywordIf("BIN_SHR", "BITSHIFTRIGHT")) {
|
||||
else if (parseKeywordIf("BIN_SHR", "BITSHIFTRIGHT", "BITWISE_RIGHT_SHIFT")) {
|
||||
parse('(');
|
||||
Field<?> x = toField(parseNumericOp());
|
||||
parse(',');
|
||||
@ -13689,7 +13694,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
case 'A':
|
||||
if (parseFunctionNameIf("ANY"))
|
||||
return ComputationalOperation.ANY;
|
||||
else if (parseFunctionNameIf("ANY_VALUE"))
|
||||
else if (parseFunctionNameIf("ANY_VALUE", "ARBITRARY"))
|
||||
return ComputationalOperation.ANY_VALUE;
|
||||
else if (parseFunctionNameIf("AVG"))
|
||||
return ComputationalOperation.AVG;
|
||||
@ -14064,6 +14069,10 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
return parseKeywordIf(keyword1) || parseKeywordIf(keyword2) || parseKeywordIf(keyword3);
|
||||
}
|
||||
|
||||
private final boolean parseKeywordIf(String keyword1, String keyword2, String keyword3, String keyword4) {
|
||||
return parseKeywordIf(keyword1) || parseKeywordIf(keyword2) || parseKeywordIf(keyword3) || parseKeywordIf(keyword4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean parseKeywordIf(String... keywords) {
|
||||
return anyMatch(keywords, k -> parseKeywordIf(k));
|
||||
|
||||
@ -108,6 +108,7 @@ implements
|
||||
case MYSQL:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
case YUGABYTEDB:
|
||||
DataType<?> cast;
|
||||
|
||||
|
||||
@ -102,6 +102,7 @@ implements
|
||||
|
||||
|
||||
case FIREBIRD:
|
||||
|
||||
return false;
|
||||
|
||||
case SQLITE:
|
||||
@ -135,6 +136,7 @@ implements
|
||||
|
||||
|
||||
case FIREBIRD:
|
||||
|
||||
ctx.visit(DSL.rpad(string, imul(DSL.length(string), count), string));
|
||||
break;
|
||||
|
||||
|
||||
@ -100,6 +100,7 @@ implements
|
||||
|
||||
|
||||
case SQLITE:
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
@ -122,6 +123,7 @@ implements
|
||||
|
||||
|
||||
case SQLITE:
|
||||
|
||||
ctx.visit(DSL.substring(string, ineg(length)));
|
||||
break;
|
||||
|
||||
|
||||
@ -67,6 +67,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -99,6 +100,7 @@ import org.jooq.RowId;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.SQLDialectCategory;
|
||||
import org.jooq.XML;
|
||||
import org.jooq.impl.SQLDataTypes.TrinoDataType;
|
||||
import org.jooq.types.DayToSecond;
|
||||
import org.jooq.types.UByte;
|
||||
import org.jooq.types.UInteger;
|
||||
@ -873,6 +875,9 @@ public final class SQLDataType {
|
||||
Class.forName(SQLiteDataType.class.getName());
|
||||
initJSR310Types(SQLITE);
|
||||
|
||||
Class.forName(TrinoDataType.class.getName());
|
||||
initJSR310Types(TRINO);
|
||||
|
||||
Class.forName(YugabyteDBDataType.class.getName());
|
||||
initJSR310Types(YUGABYTEDB);
|
||||
|
||||
|
||||
118
jOOQ/src/main/java/org/jooq/impl/SQLDataTypes.java
Normal file
118
jOOQ/src/main/java/org/jooq/impl/SQLDataTypes.java
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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 java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.OffsetTime;
|
||||
import java.time.Year;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.JSON;
|
||||
import org.jooq.JSONB;
|
||||
import org.jooq.SQLDialect;
|
||||
|
||||
/**
|
||||
* A wrapper for dialect specific, internal data types.
|
||||
* <p>
|
||||
* Starting with jOOQ 3.11.0 [#7375], these were made part of jOOQ's internals.
|
||||
* They will all be moved here, eventually.
|
||||
*/
|
||||
final class SQLDataTypes {
|
||||
|
||||
private SQLDataTypes() {}
|
||||
|
||||
static class TrinoDataType {
|
||||
|
||||
private static final SQLDialect FAMILY = SQLDialect.TRINO;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Default SQL data types and synonyms thereof
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
static final DataType<Byte> TINYINT = new BuiltInDataType<>(FAMILY, SQLDataType.TINYINT, "tinyint");
|
||||
static final DataType<Short> SMALLINT = new BuiltInDataType<>(FAMILY, SQLDataType.SMALLINT, "smallint");
|
||||
static final DataType<Integer> INT = new BuiltInDataType<>(FAMILY, SQLDataType.INTEGER, "int");
|
||||
static final DataType<Integer> INTEGER = new BuiltInDataType<>(FAMILY, SQLDataType.INTEGER, "integer");
|
||||
static final DataType<Long> BIGINT = new BuiltInDataType<>(FAMILY, SQLDataType.BIGINT, "bigint");
|
||||
static final DataType<Double> DOUBLE = new BuiltInDataType<>(FAMILY, SQLDataType.DOUBLE, "double");
|
||||
static final DataType<Double> DOUBLEPRECISION = new BuiltInDataType<>(FAMILY, SQLDataType.DOUBLE, "double precision");
|
||||
static final DataType<Double> FLOAT = new BuiltInDataType<>(FAMILY, SQLDataType.FLOAT, "float");
|
||||
static final DataType<Float> REAL = new BuiltInDataType<>(FAMILY, SQLDataType.REAL, "real");
|
||||
static final DataType<Boolean> BOOLEAN = new BuiltInDataType<>(FAMILY, SQLDataType.BOOLEAN, "boolean");
|
||||
static final DataType<BigDecimal> DECIMAL = new BuiltInDataType<>(FAMILY, SQLDataType.DECIMAL, "decimal(p, s)");
|
||||
static final DataType<String> VARCHAR = new BuiltInDataType<>(FAMILY, SQLDataType.VARCHAR, "varchar(l)", "varchar(32672)");
|
||||
static final DataType<String> CHAR = new BuiltInDataType<>(FAMILY, SQLDataType.CHAR, "char(l)");
|
||||
static final DataType<Date> DATE = new BuiltInDataType<>(FAMILY, SQLDataType.DATE, "date");
|
||||
static final DataType<Time> TIME = new BuiltInDataType<>(FAMILY, SQLDataType.TIME, "time(p)");
|
||||
static final DataType<Time> TIMEWITHOUTTIMEZONE = new BuiltInDataType<>(FAMILY, SQLDataType.TIME, "time(p) without time zone");
|
||||
static final DataType<OffsetTime> TIMEWITHTIMEZONE = new BuiltInDataType<>(FAMILY, SQLDataType.TIMEWITHTIMEZONE, "time(p) with time zone");
|
||||
static final DataType<Timestamp> TIMESTAMP = new BuiltInDataType<>(FAMILY, SQLDataType.TIMESTAMP, "timestamp(p)");
|
||||
static final DataType<Timestamp> TIMESTAMPWITHOUTTIMEZONE = new BuiltInDataType<>(FAMILY, SQLDataType.TIMESTAMP, "timestamp(p) without time zone");
|
||||
static final DataType<OffsetDateTime> TIMESTAMPWITHTIMEZONE = new BuiltInDataType<>(FAMILY, SQLDataType.TIMESTAMPWITHTIMEZONE, "timestamp(p) with time zone");
|
||||
static final DataType<Instant> INSTANT = new BuiltInDataType<>(FAMILY, SQLDataType.INSTANT, "timestamp(p) with time zone");
|
||||
static final DataType<byte[]> VARBINARY = new BuiltInDataType<>(FAMILY, SQLDataType.VARBINARY, "varbinary(l)", "varbinary(32672)");
|
||||
static final DataType<JSON> JSON = new BuiltInDataType<>(FAMILY, SQLDataType.JSON, "json");
|
||||
static final DataType<Object> OTHER = new BuiltInDataType<>(FAMILY, SQLDataType.OTHER, "other");
|
||||
static final DataType<UUID> UUID = new BuiltInDataType<>(FAMILY, SQLDataType.UUID, "uuid");
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Compatibility types for supported SQLDialect.TRINO, SQLDataTypes
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
static final DataType<Year> __YEAR = new BuiltInDataType<>(FAMILY, SQLDataType.YEAR, "smallint");
|
||||
static final DataType<String> __CLOB = new BuiltInDataType<>(FAMILY, SQLDataType.CLOB, "varchar");
|
||||
static final DataType<byte[]> __BLOB = new BuiltInDataType<>(FAMILY, SQLDataType.BLOB, "varbinary");
|
||||
static final DataType<JSONB> __JSONB = new BuiltInDataType<>(FAMILY, SQLDataType.JSONB, "json");
|
||||
static final DataType<BigDecimal> __NUMERIC = new BuiltInDataType<>(FAMILY, SQLDataType.NUMERIC, "decimal(p, s)");
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Compatibility types for supported Java types
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
static final DataType<BigInteger> __BIGINTEGER = new BuiltInDataType<>(FAMILY, SQLDataType.DECIMAL_INTEGER, "decimal(p, s)");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -115,6 +115,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
import static org.jooq.SortOrder.DESC;
|
||||
// ...
|
||||
@ -1877,6 +1878,15 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
if (getLimit().isApplicable() && getLimit().isExpression())
|
||||
toSQLReferenceLimitWithWindowFunctions(context);
|
||||
else
|
||||
toSQLReferenceLimitDefault(context, originalFields, alternativeFields);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -113,6 +113,11 @@ implements
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -162,6 +167,12 @@ implements
|
||||
|
||||
|
||||
|
||||
ctx.visit(function(N_BITWISE_LEFT_SHIFT, getDataType(), value, count));
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -113,6 +113,11 @@ implements
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -162,6 +167,12 @@ implements
|
||||
|
||||
|
||||
|
||||
ctx.visit(function(N_BITWISE_RIGHT_SHIFT, getDataType(), value, count));
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user