diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java b/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java index 5048f55a96..1b7bf44235 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java @@ -40,10 +40,12 @@ package org.jooq.impl; // ... // ... // ... +// ... import static org.jooq.SQLDialect.H2; import static org.jooq.SQLDialect.HSQLDB; import static org.jooq.SQLDialect.POSTGRES; // ... +// ... import static org.jooq.SQLDialect.SQLITE; import static org.jooq.impl.DSL.condition; import static org.jooq.impl.DSL.one; @@ -52,6 +54,7 @@ import static org.jooq.impl.Keywords.K_DISTINCT; import static org.jooq.impl.Keywords.K_FILTER; import static org.jooq.impl.Keywords.K_ORDER_BY; import static org.jooq.impl.Keywords.K_WHERE; +import static org.jooq.impl.Names.*; import static org.jooq.impl.SQLDataType.DOUBLE; import static org.jooq.impl.SQLDataType.NUMERIC; @@ -84,6 +87,10 @@ implements AggregateFunction, OrderedAggregateFunction, ArrayAggOrderByStep { + + + + static final Set SUPPORT_FILTER = SQLDialect.supportedBy(H2, HSQLDB, POSTGRES, SQLITE); static final Set SUPPORT_DISTINCT_RVE = SQLDialect.supportedBy(H2, POSTGRES); @@ -110,6 +117,23 @@ implements // XXX QueryPart API // ------------------------------------------------------------------------- + /* non-final */ void acceptFunctionName(Context ctx) { + + + + + + + + + + + + + + ctx.visit(getQualifiedName()); + } + final void acceptArguments0(Context ctx) { acceptArguments1(ctx, arguments); } @@ -134,10 +158,23 @@ implements final void acceptArguments2(Context ctx, QueryPartCollectionView> args) { if (filter == null || SUPPORT_FILTER.contains(ctx.dialect())) ctx.visit(args); + + + + else ctx.visit(args.map(arg -> DSL.when(filter, arg == ASTERISK ? one() : arg))); } + + + + + + + + + final void acceptFilterClause(Context ctx) { acceptFilterClause(ctx, filter); } diff --git a/jOOQ/src/main/java/org/jooq/impl/ArrayTable.java b/jOOQ/src/main/java/org/jooq/impl/ArrayTable.java index d942e099d3..161089f25c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ArrayTable.java +++ b/jOOQ/src/main/java/org/jooq/impl/ArrayTable.java @@ -89,9 +89,8 @@ final class ArrayTable extends AbstractTable { Class arrayType; - // TODO [#523] Solve this in a more object-oriented way... if (array.getDataType().getType().isArray()) { - arrayType = array.getDataType().getType().getComponentType(); + arrayType = array.getDataType().getArrayComponentType(); } @@ -183,6 +182,7 @@ final class ArrayTable extends AbstractTable { // arrays + case HSQLDB: case POSTGRES: return new PostgresHSQLDBTable().as(alias, fieldAliases); diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index 96d971c318..9702e6a86c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -98,8 +98,19 @@ import static org.jooq.conf.ParamType.INLINED; import static org.jooq.impl.Keywords.K_CUBE; import static org.jooq.impl.Keywords.K_DEFAULT; import static org.jooq.impl.Keywords.K_GROUPING_SETS; +import static org.jooq.impl.Names.N_AVG; +import static org.jooq.impl.Names.N_COUNT; +import static org.jooq.impl.Names.N_CUME_DIST; +import static org.jooq.impl.Names.N_DENSE_RANK; import static org.jooq.impl.Names.N_IF; import static org.jooq.impl.Names.N_IIF; +import static org.jooq.impl.Names.N_MAX; +import static org.jooq.impl.Names.N_MIN; +import static org.jooq.impl.Names.N_PERCENTILE_CONT; +import static org.jooq.impl.Names.N_PERCENTILE_DISC; +import static org.jooq.impl.Names.N_PERCENT_RANK; +import static org.jooq.impl.Names.N_RANK; +import static org.jooq.impl.Names.N_SUM; import static org.jooq.impl.Names.N_SYSTEM_TIME; import static org.jooq.impl.Names.N_VALUE; import static org.jooq.impl.PositionalWindowFunction.PositionalFunctionType.FIRST_VALUE; @@ -23298,7 +23309,7 @@ public class DSL { @NotNull @Support public static AggregateFunction count(Field field) { - return new DefaultAggregateFunction<>("count", SQLDataType.INTEGER, Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(N_COUNT, SQLDataType.INTEGER, Tools.nullSafe(field)); } /** @@ -23307,7 +23318,7 @@ public class DSL { @NotNull @Support public static AggregateFunction count(SelectFieldOrAsterisk field) { - return new DefaultAggregateFunction<>("count", SQLDataType.INTEGER, field("{0}", field)); + return new DefaultAggregateFunction<>(N_COUNT, SQLDataType.INTEGER, field("{0}", field)); } /** @@ -23329,7 +23340,7 @@ public class DSL { @NotNull @Support public static AggregateFunction countDistinct(Field field) { - return new DefaultAggregateFunction<>(true, "count", SQLDataType.INTEGER, Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(true, N_COUNT, SQLDataType.INTEGER, Tools.nullSafe(field)); } /** @@ -23338,7 +23349,7 @@ public class DSL { @NotNull @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) public static AggregateFunction countDistinct(SelectFieldOrAsterisk field) { - return new DefaultAggregateFunction<>(true, "count", SQLDataType.INTEGER, field("{0}", field)); + return new DefaultAggregateFunction<>(true, N_COUNT, SQLDataType.INTEGER, field("{0}", field)); } /** @@ -23367,7 +23378,7 @@ public class DSL { @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) public static AggregateFunction countDistinct(Field... fields) { fields = Tools.nullSafe(fields); - return fields.length == 0 ? countDistinct(asterisk()) : new DefaultAggregateFunction<>(true, "count", SQLDataType.INTEGER, fields); + return fields.length == 0 ? countDistinct(asterisk()) : new DefaultAggregateFunction<>(true, N_COUNT, SQLDataType.INTEGER, fields); } /** @@ -23641,7 +23652,7 @@ public class DSL { @NotNull @Support public static AggregateFunction max(Field field) { - return new DefaultAggregateFunction<>("max", Tools.nullSafeDataType(field), Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(N_MAX, Tools.nullSafeDataType(field), Tools.nullSafe(field)); } /** @@ -23650,7 +23661,7 @@ public class DSL { @NotNull @Support public static AggregateFunction maxDistinct(Field field) { - return new DefaultAggregateFunction<>(true, "max", Tools.nullSafeDataType(field), Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(true, N_MAX, Tools.nullSafeDataType(field), Tools.nullSafe(field)); } /** @@ -23659,7 +23670,7 @@ public class DSL { @NotNull @Support public static AggregateFunction min(Field field) { - return new DefaultAggregateFunction<>("min", Tools.nullSafeDataType(field), Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(N_MIN, Tools.nullSafeDataType(field), Tools.nullSafe(field)); } /** @@ -23668,7 +23679,7 @@ public class DSL { @NotNull @Support public static AggregateFunction minDistinct(Field field) { - return new DefaultAggregateFunction<>(true, "min", Tools.nullSafeDataType(field), Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(true, N_MIN, Tools.nullSafeDataType(field), Tools.nullSafe(field)); } /** @@ -23677,7 +23688,7 @@ public class DSL { @NotNull @Support public static AggregateFunction sum(Field field) { - return new DefaultAggregateFunction<>("sum", SQLDataType.NUMERIC, Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(N_SUM, SQLDataType.NUMERIC, Tools.nullSafe(field)); } /** @@ -23686,7 +23697,7 @@ public class DSL { @NotNull @Support public static AggregateFunction sumDistinct(Field field) { - return new DefaultAggregateFunction<>(true, "sum", SQLDataType.NUMERIC, Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(true, N_SUM, SQLDataType.NUMERIC, Tools.nullSafe(field)); } /** @@ -23733,7 +23744,7 @@ public class DSL { @NotNull @Support public static AggregateFunction avg(Field field) { - return new DefaultAggregateFunction<>("avg", SQLDataType.NUMERIC, Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(N_AVG, SQLDataType.NUMERIC, Tools.nullSafe(field)); } /** @@ -23742,7 +23753,7 @@ public class DSL { @NotNull @Support public static AggregateFunction avgDistinct(Field field) { - return new DefaultAggregateFunction<>(true, "avg", SQLDataType.NUMERIC, Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(true, N_AVG, SQLDataType.NUMERIC, Tools.nullSafe(field)); } /** @@ -23907,7 +23918,7 @@ public class DSL { @NotNull @Support({ H2, POSTGRES }) public static OrderedAggregateFunction rank(Field... fields) { - return new DefaultAggregateFunction<>("rank", SQLDataType.INTEGER, fields); + return new DefaultAggregateFunction<>(N_RANK, SQLDataType.INTEGER, fields); } /** @@ -23917,7 +23928,7 @@ public class DSL { @NotNull @Support({ H2, POSTGRES }) public static OrderedAggregateFunction rank(Collection> fields) { - return new DefaultAggregateFunction<>("rank", SQLDataType.INTEGER, fields.toArray(EMPTY_FIELD)); + return new DefaultAggregateFunction<>(N_RANK, SQLDataType.INTEGER, fields.toArray(EMPTY_FIELD)); } /** @@ -23927,7 +23938,7 @@ public class DSL { @NotNull @Support({ H2, POSTGRES }) public static OrderedAggregateFunction denseRank(Field... fields) { - return new DefaultAggregateFunction<>("dense_rank", SQLDataType.INTEGER, fields); + return new DefaultAggregateFunction<>(N_DENSE_RANK, SQLDataType.INTEGER, fields); } /** @@ -23937,7 +23948,7 @@ public class DSL { @NotNull @Support({ H2, POSTGRES }) public static OrderedAggregateFunction denseRank(Collection> fields) { - return new DefaultAggregateFunction<>("dense_rank", SQLDataType.INTEGER, fields.toArray(EMPTY_FIELD)); + return new DefaultAggregateFunction<>(N_DENSE_RANK, SQLDataType.INTEGER, fields.toArray(EMPTY_FIELD)); } /** @@ -23947,7 +23958,7 @@ public class DSL { @NotNull @Support({ H2, POSTGRES }) public static OrderedAggregateFunction percentRank(Field... fields) { - return new DefaultAggregateFunction<>("percent_rank", SQLDataType.INTEGER, fields); + return new DefaultAggregateFunction<>(N_PERCENT_RANK, SQLDataType.INTEGER, fields); } /** @@ -23957,7 +23968,7 @@ public class DSL { @NotNull @Support({ H2, POSTGRES }) public static OrderedAggregateFunction percentRank(Collection> fields) { - return new DefaultAggregateFunction<>("percent_rank", SQLDataType.INTEGER, fields.toArray(EMPTY_FIELD)); + return new DefaultAggregateFunction<>(N_PERCENT_RANK, SQLDataType.INTEGER, fields.toArray(EMPTY_FIELD)); } /** @@ -23967,7 +23978,7 @@ public class DSL { @NotNull @Support({ H2, POSTGRES }) public static OrderedAggregateFunction cumeDist(Field... fields) { - return new DefaultAggregateFunction<>("cume_dist", SQLDataType.NUMERIC, fields); + return new DefaultAggregateFunction<>(N_CUME_DIST, SQLDataType.NUMERIC, fields); } /** @@ -23977,7 +23988,7 @@ public class DSL { @NotNull @Support({ H2, POSTGRES }) public static OrderedAggregateFunction cumeDist(Collection> fields) { - return new DefaultAggregateFunction<>("cume_dist", SQLDataType.NUMERIC, fields.toArray(EMPTY_FIELD)); + return new DefaultAggregateFunction<>(N_CUME_DIST, SQLDataType.NUMERIC, fields.toArray(EMPTY_FIELD)); } /** @@ -24007,7 +24018,7 @@ public class DSL { @NotNull @Support({ H2, POSTGRES }) public static OrderedAggregateFunction percentileCont(Field field) { - return new DefaultAggregateFunction<>("percentile_cont", SQLDataType.NUMERIC, Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(N_PERCENTILE_CONT, SQLDataType.NUMERIC, Tools.nullSafe(field)); } /** @@ -24037,7 +24048,7 @@ public class DSL { @NotNull @Support({ H2, POSTGRES }) public static OrderedAggregateFunction percentileDisc(Field field) { - return new DefaultAggregateFunction<>("percentile_disc", SQLDataType.NUMERIC, Tools.nullSafe(field)); + return new DefaultAggregateFunction<>(N_PERCENTILE_DISC, SQLDataType.NUMERIC, Tools.nullSafe(field)); } // ------------------------------------------------------------------------- diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultAggregateFunction.java b/jOOQ/src/main/java/org/jooq/impl/DefaultAggregateFunction.java index bb8f3e6127..b297837ebb 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultAggregateFunction.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultAggregateFunction.java @@ -131,8 +131,4 @@ class DefaultAggregateFunction extends AbstractAggregateFunction { acceptArguments0(ctx); ctx.sql(')'); } - - /* non-final */ void acceptFunctionName(Context ctx) { - ctx.visit(getQualifiedName()); - } } diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultBinding.java b/jOOQ/src/main/java/org/jooq/impl/DefaultBinding.java index c3e5d86495..e4fabce117 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultBinding.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultBinding.java @@ -1481,6 +1481,16 @@ public class DefaultBinding implements Binding { ctx.render().sql(value.toString()); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void set0(BindingSetStatementContext ctx, BigDecimal value) throws SQLException { if (BIND_AS_STRING.contains(ctx.dialect())) @@ -1532,6 +1542,16 @@ public class DefaultBinding implements Binding { ctx.render().sql(value.toString()); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void set0(BindingSetStatementContext ctx, BigInteger value) throws SQLException { if (BIND_AS_STRING.contains(ctx.dialect())) @@ -1580,6 +1600,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void set0(BindingSetStatementContext ctx, Blob value) throws SQLException { ctx.statement().setBlob(ctx.index(), value); @@ -1679,6 +1709,14 @@ public class DefaultBinding implements Binding { + + + + + + + + @@ -1700,6 +1738,8 @@ public class DefaultBinding implements Binding { + + super.setNull0(ctx); } @@ -1749,6 +1789,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, Byte value) { ctx.render().sql(value); @@ -1802,6 +1852,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, byte[] value) { // [#1154] Binary data cannot always be inlined @@ -1933,6 +1993,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void set0(BindingSetStatementContext ctx, Clob value) throws SQLException { ctx.statement().setClob(ctx.index(), value); @@ -1971,6 +2041,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, Date value) { // [#1156] DATE / TIME inlining is very vendor-specific @@ -2335,6 +2415,16 @@ public class DefaultBinding implements Binding { } } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, Double value) { @@ -2508,6 +2598,16 @@ public class DefaultBinding implements Binding { return DefaultDoubleBinding.fixInfinity(scope, doubleSupplier, stringSupplier, () -> Float.POSITIVE_INFINITY, () -> Float.NEGATIVE_INFINITY); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, Float value) { @@ -2582,6 +2682,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, Integer value) { ctx.render().sql(value); @@ -2629,6 +2739,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, Long value) { ctx.render().sql(value); @@ -2852,6 +2972,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, OffsetDateTime value) { SQLDialect family = ctx.family(); @@ -3033,6 +3163,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, OffsetTime value) { @@ -3148,6 +3288,11 @@ public class DefaultBinding implements Binding { delegate = new DefaultOffsetDateTimeBinding<>(SQLDataType.OFFSETDATETIME, Converters.of(CONVERTER, converter())); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + delegate.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, Instant value) throws SQLException { delegate.sqlInline0(ctx, CONVERTER.to(value)); @@ -3204,6 +3349,7 @@ public class DefaultBinding implements Binding { @Override final void setNull0(BindingSetStatementContext ctx) throws SQLException { + switch (ctx.family()) { @@ -3219,8 +3365,15 @@ public class DefaultBinding implements Binding { - // [#729] In the absence of the correct JDBC type, try setObject - ctx.statement().setObject(ctx.index(), null); + + + + + // [#729] In the absence of the correct JDBC type, try setObject + default: + ctx.statement().setObject(ctx.index(), null); + break; + } } @Override @@ -3647,6 +3800,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, Short value) { ctx.render().sql(value); @@ -3694,6 +3857,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void set0(BindingSetStatementContext ctx, String value) throws SQLException { ctx.statement().setString(ctx.index(), value); @@ -3767,6 +3940,16 @@ public class DefaultBinding implements Binding { this.fallback = new DefaultStringBinding<>(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override void sqlInline0(BindingSQLContext ctx, String value) throws SQLException { if (NO_SUPPORT_NVARCHAR.contains(ctx.dialect())) { @@ -3849,6 +4032,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, Time value) { switch (ctx.family()) { @@ -3953,6 +4146,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void sqlInline0(BindingSQLContext ctx, Timestamp value) { @@ -4049,6 +4252,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void set0(BindingSetStatementContext ctx, UUID value) throws SQLException { switch (ctx.family()) { @@ -4167,6 +4380,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override void sqlInline0(BindingSQLContext ctx, JSON value) throws SQLException { super.sqlInline0(ctx, value); @@ -4224,6 +4447,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override void sqlInline0(BindingSQLContext ctx, JSONB value) throws SQLException { if (EMULATE_AS_BLOB.contains(ctx.dialect())) { @@ -4322,6 +4555,16 @@ public class DefaultBinding implements Binding { super(dataType, converter); } + @Override + final void setNull0(BindingSetStatementContext ctx) throws SQLException { + + + + + + super.setNull0(ctx); + } + @Override final void set0(BindingSetStatementContext ctx, XML value) throws SQLException { ctx.statement().setString(ctx.index(), value.toString()); diff --git a/jOOQ/src/main/java/org/jooq/impl/FieldMapsForInsert.java b/jOOQ/src/main/java/org/jooq/impl/FieldMapsForInsert.java index 9c36c08053..e006b6ce71 100644 --- a/jOOQ/src/main/java/org/jooq/impl/FieldMapsForInsert.java +++ b/jOOQ/src/main/java/org/jooq/impl/FieldMapsForInsert.java @@ -41,6 +41,7 @@ import static java.lang.Boolean.TRUE; import static org.jooq.Clause.FIELD_ROW; import static org.jooq.Clause.INSERT_SELECT; import static org.jooq.Clause.INSERT_VALUES; +// ... import static org.jooq.SQLDialect.POSTGRES; // ... import static org.jooq.impl.DSL.name; diff --git a/jOOQ/src/main/java/org/jooq/impl/GenerateSeries.java b/jOOQ/src/main/java/org/jooq/impl/GenerateSeries.java index 6775909222..e14617be3f 100644 --- a/jOOQ/src/main/java/org/jooq/impl/GenerateSeries.java +++ b/jOOQ/src/main/java/org/jooq/impl/GenerateSeries.java @@ -39,17 +39,21 @@ package org.jooq.impl; import static org.jooq.SQLDialect.*; import static org.jooq.conf.ParamType.INLINED; +import static org.jooq.impl.DSL.function; import static org.jooq.impl.DSL.inline; // ... import static org.jooq.impl.DSL.one; import static org.jooq.impl.DSL.select; +import static org.jooq.impl.DSL.unnest; import static org.jooq.impl.DSL.unquotedName; import static org.jooq.impl.DSL.withRecursive; import static org.jooq.impl.Internal.iadd; import static org.jooq.impl.Internal.imul; import static org.jooq.impl.Internal.isub; +import static org.jooq.impl.Names.N_GENERATE_ARRAY; import static org.jooq.impl.Names.N_GENERATE_SERIES; import static org.jooq.impl.Names.N_SYSTEM_RANGE; +import static org.jooq.impl.Names.N_UNNEST; import static org.jooq.impl.SQLDataType.INTEGER; import static org.jooq.impl.Tools.visitSubquery; @@ -77,6 +81,8 @@ final class GenerateSeries extends AbstractTable> implements Au + + private final Field from; private final Field to; private final Field step; @@ -146,6 +152,12 @@ final class GenerateSeries extends AbstractTable> implements Au + + + + + + else { if (step == null) @@ -163,7 +175,7 @@ final class GenerateSeries extends AbstractTable> implements Au @Override final FieldsImpl> fields0() { - return new FieldsImpl<>(DSL.field(N_GENERATE_SERIES, Integer.class)); + return new FieldsImpl<>(DSL.field(DSL.name(name, N_GENERATE_SERIES), Integer.class)); } @Override // Avoid AbstractTable implementation @@ -177,6 +189,10 @@ final class GenerateSeries extends AbstractTable> implements Au return as(name); else if (EMULATE_SYSTEM_RANGE.contains(ctx.dialect())) return as(name, name); + + + + else return null; } diff --git a/jOOQ/src/main/java/org/jooq/impl/ModeDeferred.java b/jOOQ/src/main/java/org/jooq/impl/ModeDeferred.java index f1a6a161da..af128ba885 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ModeDeferred.java +++ b/jOOQ/src/main/java/org/jooq/impl/ModeDeferred.java @@ -37,6 +37,8 @@ */ package org.jooq.impl; +import static org.jooq.impl.Names.N_MODE; + import org.jooq.AggregateFilterStep; import org.jooq.DataType; import org.jooq.Field; @@ -57,6 +59,6 @@ final class ModeDeferred implements OrderedAggregateFunctionOfDeferredType { ? ((AbstractField) field).getDataType() : (DataType) SQLDataType.NUMERIC; - return new DefaultAggregateFunction<>("mode", type).withinGroupOrderBy(field); + return new DefaultAggregateFunction<>(N_MODE, type).withinGroupOrderBy(field); } } diff --git a/jOOQ/src/main/java/org/jooq/impl/Names.java b/jOOQ/src/main/java/org/jooq/impl/Names.java index 3525ac5a77..f67388fcf6 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Names.java +++ b/jOOQ/src/main/java/org/jooq/impl/Names.java @@ -42,7 +42,6 @@ import static org.jooq.impl.DSL.unquotedName; import org.jooq.Name; // ... -import org.jooq.QueryPart; /** * An internal {@link Name} cache. @@ -51,324 +50,336 @@ import org.jooq.QueryPart; */ final class Names { - static final Name N_ARRAY_TABLE = name("array_table"); - static final Name N_COLUMN_VALUE = name("COLUMN_VALUE"); + static final Name N_ARRAY_TABLE = name("array_table"); + static final Name N_COLUMN_VALUE = name("COLUMN_VALUE"); - static final Name N_ABS = unquotedName("abs"); - static final Name N_ACOS = unquotedName("acos"); - static final Name N_ADD_DAYS = unquotedName("add_days"); - static final Name N_ADD_HOURS = unquotedName("add_hours"); - static final Name N_ADD_MINUTES = unquotedName("add_minutes"); - static final Name N_ADD_MONTHS = unquotedName("add_months"); - static final Name N_ADD_SECONDS = unquotedName("add_seconds"); - static final Name N_ADD_YEARS = unquotedName("add_years"); - static final Name N_ANY = unquotedName("any"); - static final Name N_ARRAY = unquotedName("array"); - static final Name N_ARRAY_AGG = unquotedName("array_agg"); - static final Name N_ARRAY_GET = unquotedName("array_get"); - static final Name N_ARRAY_LENGTH = unquotedName("array_length"); - static final Name N_ASC = unquotedName("asc"); - static final Name N_ASCII = unquotedName("ascii"); - static final Name N_ASCII_CHAR = unquotedName("ascii_char"); - static final Name N_ASCII_VAL = unquotedName("ascii_val"); - static final Name N_ASIN = unquotedName("asin"); - static final Name N_ATAN = unquotedName("atan"); - static final Name N_ATAN2 = unquotedName("atan2"); - static final Name N_ATN = unquotedName("atn"); - static final Name N_ATN2 = unquotedName("atn2"); - static final Name N_BIT_COUNT = unquotedName("bit_count"); - static final Name N_BIT_LENGTH = unquotedName("bit_length"); - static final Name N_BOOLAND_AGG = unquotedName("booland_agg"); - static final Name N_BOOLOR_AGG = unquotedName("boolor_agg"); - static final Name N_BOOL_AND = unquotedName("bool_and"); - static final Name N_BOOL_OR = unquotedName("bool_or"); - static final Name N_BYTE_LENGTH = unquotedName("byte_length"); - static final Name N_CARDINALITY = unquotedName("cardinality"); - static final Name N_CASE = unquotedName("case"); - static final Name N_CAST = unquotedName("cast"); - static final Name N_CEIL = unquotedName("ceil"); - static final Name N_CEILING = unquotedName("ceiling"); - static final Name N_CHAR = unquotedName("char"); - static final Name N_CHARINDEX = unquotedName("charindex"); - static final Name N_CHAR_LENGTH = unquotedName("char_length"); - static final Name N_CHOOSE = unquotedName("choose"); - static final Name N_CHR = unquotedName("chr"); - static final Name N_COALESCE = unquotedName("coalesce"); - static final Name N_COLLECT = unquotedName("collect"); - static final Name N_CONCAT = unquotedName("concat"); - static final Name N_CONNECT_BY_IS_CYCLE = unquotedName("connect_by_iscycle"); - static final Name N_CONNECT_BY_IS_LEAF = unquotedName("connect_by_isleaf"); - static final Name N_CONNECT_BY_ROOT = unquotedName("connect_by_root"); - static final Name N_CONVERT = unquotedName("convert"); - static final Name N_CORR = unquotedName("corr"); - static final Name N_COS = unquotedName("cos"); - static final Name N_COSH = unquotedName("cosh"); - static final Name N_COT = unquotedName("cot"); - static final Name N_COTH = unquotedName("coth"); - static final Name N_COUNT = unquotedName("count"); - static final Name N_COUNTSET = unquotedName("countset"); - static final Name N_COVAR_POP = unquotedName("covar_pop"); - static final Name N_COVAR_SAMP = unquotedName("covar_samp"); - static final Name N_CURRENTUSER = unquotedName("currentuser"); - static final Name N_CURRENT_BIGDATETIME = unquotedName("current_bigdatetime"); - static final Name N_CURRENT_CATALOG = unquotedName("current_catalog"); - static final Name N_CURRENT_DATABASE = unquotedName("current_database"); - static final Name N_CURRENT_DATE = unquotedName("current_date"); - static final Name N_CURRENT_SCHEMA = unquotedName("current_schema"); - static final Name N_CURRENT_TIME = unquotedName("current_time"); - static final Name N_CURRENT_TIMESTAMP = unquotedName("current_timestamp"); - static final Name N_CURRENT_USER = unquotedName("current_user"); - static final Name N_CURRVAL = unquotedName("currval"); - static final Name N_DATALENGTH = unquotedName("datalength"); - static final Name N_DATEADD = unquotedName("dateadd"); - static final Name N_DATEDIFF = unquotedName("datediff"); - static final Name N_DATEPART = unquotedName("datepart"); - static final Name N_DATE_ADD = unquotedName("date_add"); - static final Name N_DATE_DIFF = unquotedName("date_diff"); - static final Name N_DATE_TRUNC = unquotedName("date_trunc"); - static final Name N_DAYOFWEEK = unquotedName("dayofweek"); - static final Name N_DAYOFYEAR = unquotedName("dayofyear"); - static final Name N_DAYS = unquotedName("days"); - static final Name N_DAYS_BETWEEN = unquotedName("days_between"); - static final Name N_DB_NAME = unquotedName("db_name"); - static final Name N_DECODE = unquotedName("decode"); - static final Name N_DEFAULT = unquotedName("default"); - static final Name N_DEGREES = unquotedName("degrees"); - static final Name N_DELETING = unquotedName("deleting"); - static final Name N_DIGITS = unquotedName("digits"); - static final Name N_DUAL = unquotedName("dual"); - static final Name N_E = unquotedName("e"); - static final Name N_EULER = unquotedName("e"); - static final Name N_EVERY = unquotedName("every"); - static final Name N_EXP = unquotedName("exp"); - static final Name N_EXTRACT = unquotedName("extract"); - static final Name N_FIELD = unquotedName("field"); - static final Name N_FORMAT = unquotedName("format"); - static final Name N_FLASHBACK = unquotedName("flashback"); - static final Name N_FLOOR = unquotedName("floor"); - static final Name N_FUNCTION = unquotedName("function"); - static final Name N_GENERATE_SERIES = unquotedName("generate_series"); - static final Name N_GENERATE_UNIQUE = unquotedName("generate_unique"); - static final Name N_GENERATE_UUID = unquotedName("generate_uuid"); - static final Name N_GENGUID = unquotedName("genguid"); - static final Name N_GEN_ID = unquotedName("gen_id"); - static final Name N_GEN_RANDOM_UUID = unquotedName("gen_random_uuid"); - static final Name N_GEN_UUID = unquotedName("gen_uuid"); - static final Name N_GETDATE = unquotedName("getdate"); - static final Name N_GREATEST = unquotedName("greatest"); - static final Name N_GROUP_CONCAT = unquotedName("group_concat"); - static final Name N_HASHBYTES = unquotedName("hashbytes"); - static final Name N_HASH_MD5 = unquotedName("hash_md5"); - static final Name N_HEX = unquotedName("hex"); - static final Name N_IF = unquotedName("if"); - static final Name N_IFNULL = unquotedName("ifnull"); - static final Name N_IIF = unquotedName("iif"); - static final Name N_INSERT = unquotedName("insert"); - static final Name N_INSERTING = unquotedName("inserting"); - static final Name N_INSTR = unquotedName("instr"); - static final Name N_ISJSON = unquotedName("isjson"); - static final Name N_JOIN = unquotedName("join"); - static final Name N_JSONB_AGG = unquotedName("jsonb_agg"); - static final Name N_JSONB_BUILD_ARRAY = unquotedName("jsonb_build_array"); - static final Name N_JSONB_OBJECT_AGG = unquotedName("jsonb_object_agg"); - static final Name N_JSONB_PATH_EXISTS = unquotedName("jsonb_path_exists"); - static final Name N_JSONB_PATH_QUERY_FIRST = unquotedName("jsonb_path_query_first"); - static final Name N_JSON_AGG = unquotedName("json_agg"); - static final Name N_JSON_ARRAY = unquotedName("json_array"); - static final Name N_JSON_ARRAYAGG = unquotedName("json_arrayagg"); - static final Name N_JSON_BUILD_ARRAY = unquotedName("json_build_array"); - static final Name N_JSON_CONTAINS_PATH = unquotedName("json_contains_path"); - static final Name N_JSON_EXTRACT = unquotedName("json_extract"); - static final Name N_JSON_MERGE = unquotedName("json_merge"); - static final Name N_JSON_MERGE_PRESERVE = unquotedName("json_merge_preserve"); - static final Name N_JSON_OBJECT = unquotedName("json_object"); - static final Name N_JSON_OBJECTAGG = unquotedName("json_objectagg"); - static final Name N_JSON_OBJECT_AGG = unquotedName("json_object_agg"); - static final Name N_JSON_QUOTE = unquotedName("json_quote"); - static final Name N_JSON_TABLE = unquotedName("json_table"); - static final Name N_JSON_VALID = unquotedName("json_valid"); - static final Name N_JSON_VALUE = unquotedName("json_value"); - static final Name N_LCASE = unquotedName("lcase"); - static final Name N_LEAST = unquotedName("least"); - static final Name N_LEFT = unquotedName("left"); - static final Name N_LEN = unquotedName("len"); - static final Name N_LENGTH = unquotedName("length"); - static final Name N_LENGTHB = unquotedName("lengthb"); - static final Name N_LEVEL = unquotedName("level"); - static final Name N_LIST = unquotedName("list"); - static final Name N_LISTAGG = unquotedName("listagg"); - static final Name N_LN = unquotedName("ln"); - static final Name N_LOCATE = unquotedName("locate"); - static final Name N_LOCK_TIMEOUT = unquotedName("lock_timeout"); - static final Name N_LOG = unquotedName("log"); - static final Name N_LOG10 = unquotedName("log10"); - static final Name N_LOGICAL_AND = unquotedName("logical_and"); - static final Name N_LOGICAL_OR = unquotedName("logical_or"); - static final Name N_LOGN = unquotedName("logn"); - static final Name N_LOWER = unquotedName("lower"); - static final Name N_LPAD = unquotedName("lpad"); - static final Name N_LTRIM = unquotedName("ltrim"); - static final Name N_MAP = unquotedName("map"); - static final Name N_MAX = unquotedName("max"); - static final Name N_MAXVALUE = unquotedName("maxvalue"); - static final Name N_MD5 = unquotedName("md5"); - static final Name N_MEDIAN = unquotedName("median"); - static final Name N_MID = unquotedName("mid"); - static final Name N_MIN = unquotedName("min"); - static final Name N_MINVALUE = unquotedName("minvalue"); - static final Name N_MOD = unquotedName("mod"); - static final Name N_MODE = unquotedName("mode"); - static final Name N_MUL = unquotedName("mul"); - static final Name N_NANO100_BETWEEN = unquotedName("nano100_between"); - static final Name N_NEWID = unquotedName("newid"); - static final Name N_NEXTVAL = unquotedName("nextval"); - static final Name N_NOT = unquotedName("not"); - static final Name N_NOW = unquotedName("now"); - static final Name N_NTILE = unquotedName("ntile"); - static final Name N_NULLIF = unquotedName("nullif"); - static final Name N_NVL = unquotedName("nvl"); - static final Name N_NVL2 = unquotedName("nvl2"); - static final Name N_OCTET_LENGTH = unquotedName("octet_length"); - static final Name N_OPENJSON = unquotedName("openjson"); - static final Name N_OPENXML = unquotedName("openxml"); - static final Name N_OREPLACE = unquotedName("oreplace"); - static final Name N_OTRANSLATE = unquotedName("otranslate"); - static final Name N_OVERLAY = unquotedName("overlay"); - static final Name N_PI = unquotedName("pi"); - static final Name N_PIVOT = unquotedName("pivot"); - static final Name N_PLPGSQL = unquotedName("plpgsql"); - static final Name N_POSITION = unquotedName("position"); - static final Name N_POWER = unquotedName("power"); - static final Name N_PRINTF = unquotedName("printf"); - static final Name N_PRIOR = unquotedName("prior"); - static final Name N_PRODUCT = unquotedName("product"); - static final Name N_RADIANS = unquotedName("radians"); - static final Name N_RAND = unquotedName("rand"); - static final Name N_RANDOM = unquotedName("random"); - static final Name N_RANDOMBLOB = unquotedName("randomblob"); - static final Name N_RANDOM_UUID = unquotedName("random_uuid"); - static final Name N_RATIO_TO_REPORT = unquotedName("ratio_to_report"); - static final Name N_RAWTOHEX = unquotedName("rawtohex"); - static final Name N_REGEXP_REPLACE = unquotedName("regexp_replace"); - static final Name N_REGEX_REPLACE = unquotedName("regex_replace"); - static final Name N_REGR_AVGX = unquotedName("regr_avgx"); - static final Name N_REGR_AVGY = unquotedName("regr_avgy"); - static final Name N_REGR_COUNT = unquotedName("regr_count"); - static final Name N_REGR_INTERCEPT = unquotedName("regr_intercept"); - static final Name N_REGR_R2 = unquotedName("regr_r2"); - static final Name N_REGR_SLOPE = unquotedName("regr_slope"); - static final Name N_REGR_SXX = unquotedName("regr_sxx"); - static final Name N_REGR_SXY = unquotedName("regr_sxy"); - static final Name N_REGR_SYY = unquotedName("regr_syy"); - static final Name N_REPEAT = unquotedName("repeat"); - static final Name N_REPLACE = unquotedName("replace"); - static final Name N_REPLICATE = unquotedName("replicate"); - static final Name N_REVERSE = unquotedName("reverse"); - static final Name N_RIGHT = unquotedName("right"); - static final Name N_RND = unquotedName("rnd"); - static final Name N_ROLLUP = unquotedName("rollup"); - static final Name N_ROUND = unquotedName("round"); - static final Name N_ROUND_DOWN = unquotedName("round_down"); - static final Name N_ROW = unquotedName("row"); - static final Name N_ROWNUM = unquotedName("rownum"); - static final Name N_ROWSFROM = unquotedName("rowsfrom"); - static final Name N_ROW_NUMBER = unquotedName("row_number"); - static final Name N_RPAD = unquotedName("rpad"); - static final Name N_RTRIM = unquotedName("rtrim"); - static final Name N_SCHEMA_NAME = unquotedName("schema_name"); - static final Name N_SECONDS_BETWEEN = unquotedName("seconds_between"); - static final Name N_SELECT = unquotedName("select"); - static final Name N_SGN = unquotedName("sgn"); - static final Name N_SIGN = unquotedName("sign"); - static final Name N_SIN = unquotedName("sin"); - static final Name N_SINH = unquotedName("sinh"); - static final Name N_SPACE = unquotedName("space"); - static final Name N_SPLIT = unquotedName("split"); - static final Name N_SPLIT_PART = unquotedName("split_part"); - static final Name N_SQL_TSI_DAY = unquotedName("sql_tsi_day"); - static final Name N_SQL_TSI_FRAC_SECOND = unquotedName("sql_tsi_frac_second"); - static final Name N_SQL_TSI_HOUR = unquotedName("sql_tsi_hour"); - static final Name N_SQL_TSI_MILLI_SECOND = unquotedName("sql_tsi_milli_second"); - static final Name N_SQL_TSI_MINUTE = unquotedName("sql_tsi_minute"); - static final Name N_SQL_TSI_MONTH = unquotedName("sql_tsi_month"); - static final Name N_SQL_TSI_QUARTER = unquotedName("sql_tsi_quarter"); - static final Name N_SQL_TSI_SECOND = unquotedName("sql_tsi_second"); - static final Name N_SQL_TSI_WEEK = unquotedName("sql_tsi_week"); - static final Name N_SQL_TSI_YEAR = unquotedName("sql_tsi_year"); - static final Name N_SQR = unquotedName("sqr"); - static final Name N_SQRT = unquotedName("sqrt"); - static final Name N_SQUARE = unquotedName("square"); - static final Name N_STANDARD_HASH = unquotedName("standard_hash"); - static final Name N_STATS_MODE = unquotedName("stats_mode"); - static final Name N_STDDEV = unquotedName("stddev"); - static final Name N_STDDEV_POP = unquotedName("stddev_pop"); - static final Name N_STDDEV_SAMP = unquotedName("stddev_samp"); - static final Name N_STDEV = unquotedName("stdev"); - static final Name N_STDEVP = unquotedName("stdevp"); - static final Name N_STDEV_SAMP = unquotedName("stdev_samp"); - static final Name N_STRFTIME = unquotedName("strftime"); - static final Name N_STRING_AGG = unquotedName("string_agg"); - static final Name N_STRREVERSE = unquotedName("strreverse"); - static final Name N_STR_REPLACE = unquotedName("str_replace"); - static final Name N_SUBSTR = unquotedName("substr"); - static final Name N_SUBSTRING = unquotedName("substring"); - static final Name N_SUBSTRING_INDEX = unquotedName("substring_index"); - static final Name N_SYSTEM_RANGE = unquotedName("system_range"); - static final Name N_SYSTEM_TIME = unquotedName("system_time"); - static final Name N_SYSUUID = unquotedName("sysuuid"); - static final Name N_SYS_CONNECT_BY_PATH = unquotedName("sys_connect_by_path"); - static final Name N_SYS_GUID = unquotedName("sys_guid"); - static final Name N_T = unquotedName("t"); - static final Name N_TAN = unquotedName("tan"); - static final Name N_TANH = unquotedName("tanh"); - static final Name N_TAU = unquotedName("tau"); - static final Name N_TIMESTAMPADD = unquotedName("timestampadd"); - static final Name N_TIMESTAMPDIFF = unquotedName("timestampdiff"); - static final Name N_TO_CHAR = unquotedName("to_char"); - static final Name N_TO_CLOB = unquotedName("to_clob"); - static final Name N_TO_DATE = unquotedName("to_date"); - static final Name N_TO_HEX = unquotedName("to_hex"); - static final Name N_TO_NUMBER = unquotedName("to_number"); - static final Name N_TO_TIMESTAMP = unquotedName("to_timestamp"); - static final Name N_TRANSLATE = unquotedName("translate"); - static final Name N_TRIM = unquotedName("trim"); - static final Name N_TRUNC = unquotedName("trunc"); - static final Name N_TRUNCATE = unquotedName("truncate"); - static final Name N_TRUNCNUM = unquotedName("truncnum"); - static final Name N_UCASE = unquotedName("ucase"); - static final Name N_UPDATING = unquotedName("updating"); - static final Name N_UPPER = unquotedName("upper"); - static final Name N_USER = unquotedName("user"); - static final Name N_UUID = unquotedName("uuid"); - static final Name N_UUID_GENERATE = unquotedName("uuid_generate"); - static final Name N_UUID_STRING = unquotedName("uuid_string"); - static final Name N_UUID_TO_CHAR = unquotedName("uuid_to_char"); - static final Name N_VALUE = unquotedName("value"); - static final Name N_VALUES = unquotedName("values"); - static final Name N_VAR = unquotedName("var"); - static final Name N_VARIANCE = unquotedName("variance"); - static final Name N_VARIANCE_SAMP = unquotedName("variance_samp"); - static final Name N_VARP = unquotedName("varp"); - static final Name N_VAR_POP = unquotedName("var_pop"); - static final Name N_VAR_SAMP = unquotedName("var_samp"); - static final Name N_WEEKDAY = unquotedName("weekday"); - static final Name N_WIDTH_BUCKET = unquotedName("width_bucket"); - static final Name N_XMLAGG = unquotedName("xmlagg"); - static final Name N_XMLATTRIBUTES = unquotedName("xmlattributes"); - static final Name N_XMLCOMMENT = unquotedName("xmlcomment"); - static final Name N_XMLCONCAT = unquotedName("xmlconcat"); - static final Name N_XMLDOCUMENT = unquotedName("xmldocument"); - static final Name N_XMLELEMENT = unquotedName("xmlelement"); - static final Name N_XMLFOREST = unquotedName("xmlforest"); - static final Name N_XMLPARSE = unquotedName("xmlparse"); - static final Name N_XMLPI = unquotedName("xmlpi"); - static final Name N_XMLQUERY = unquotedName("xmlquery"); - static final Name N_XMLROOT = unquotedName("xmlroot"); - static final Name N_XMLSERIALIZE = unquotedName("xmlserialize"); - static final Name N_XMLTABLE = unquotedName("xmltable"); - static final Name N_XMLTEXT = unquotedName("xmltext"); - static final Name N_XPATH = unquotedName("xpath"); - static final Name N_ZEROBLOB = unquotedName("zeroblob"); + static final Name N_ABS = unquotedName("abs"); + static final Name N_ACOS = unquotedName("acos"); + static final Name N_ADD_DAYS = unquotedName("add_days"); + static final Name N_ADD_HOURS = unquotedName("add_hours"); + static final Name N_ADD_MINUTES = unquotedName("add_minutes"); + static final Name N_ADD_MONTHS = unquotedName("add_months"); + static final Name N_ADD_SECONDS = unquotedName("add_seconds"); + static final Name N_ADD_YEARS = unquotedName("add_years"); + static final Name N_ANY = unquotedName("any"); + static final Name N_ARRAY = unquotedName("array"); + static final Name N_ARRAY_AGG = unquotedName("array_agg"); + static final Name N_ARRAY_GET = unquotedName("array_get"); + static final Name N_ARRAY_LENGTH = unquotedName("array_length"); + static final Name N_ASC = unquotedName("asc"); + static final Name N_ASCII = unquotedName("ascii"); + static final Name N_ASCII_CHAR = unquotedName("ascii_char"); + static final Name N_ASCII_VAL = unquotedName("ascii_val"); + static final Name N_ASIN = unquotedName("asin"); + static final Name N_ATAN = unquotedName("atan"); + static final Name N_ATAN2 = unquotedName("atan2"); + static final Name N_ATN = unquotedName("atn"); + static final Name N_ATN2 = unquotedName("atn2"); + static final Name N_AVG = unquotedName("avg"); + static final Name N_BIT_COUNT = unquotedName("bit_count"); + static final Name N_BIT_LENGTH = unquotedName("bit_length"); + static final Name N_BOOLAND_AGG = unquotedName("booland_agg"); + static final Name N_BOOLOR_AGG = unquotedName("boolor_agg"); + static final Name N_BOOL_AND = unquotedName("bool_and"); + static final Name N_BOOL_OR = unquotedName("bool_or"); + static final Name N_BYTE_LENGTH = unquotedName("byte_length"); + static final Name N_CARDINALITY = unquotedName("cardinality"); + static final Name N_CASE = unquotedName("case"); + static final Name N_CAST = unquotedName("cast"); + static final Name N_CEIL = unquotedName("ceil"); + static final Name N_CEILING = unquotedName("ceiling"); + static final Name N_CHAR = unquotedName("char"); + static final Name N_CHARINDEX = unquotedName("charindex"); + static final Name N_CHAR_LENGTH = unquotedName("char_length"); + static final Name N_CHOOSE = unquotedName("choose"); + static final Name N_CHR = unquotedName("chr"); + static final Name N_COALESCE = unquotedName("coalesce"); + static final Name N_COLLECT = unquotedName("collect"); + static final Name N_CONCAT = unquotedName("concat"); + static final Name N_CONNECT_BY_IS_CYCLE = unquotedName("connect_by_iscycle"); + static final Name N_CONNECT_BY_IS_LEAF = unquotedName("connect_by_isleaf"); + static final Name N_CONNECT_BY_ROOT = unquotedName("connect_by_root"); + static final Name N_CONVERT = unquotedName("convert"); + static final Name N_CORR = unquotedName("corr"); + static final Name N_COS = unquotedName("cos"); + static final Name N_COSH = unquotedName("cosh"); + static final Name N_COT = unquotedName("cot"); + static final Name N_COTH = unquotedName("coth"); + static final Name N_COUNT = unquotedName("count"); + static final Name N_COUNTIF = unquotedName("countif"); + static final Name N_COUNTSET = unquotedName("countset"); + static final Name N_COUNT_IF = unquotedName("count_if"); + static final Name N_COVAR_POP = unquotedName("covar_pop"); + static final Name N_COVAR_SAMP = unquotedName("covar_samp"); + static final Name N_CUME_DIST = unquotedName("cume_dist"); + static final Name N_CURRENTUSER = unquotedName("currentuser"); + static final Name N_CURRENT_BIGDATETIME = unquotedName("current_bigdatetime"); + static final Name N_CURRENT_CATALOG = unquotedName("current_catalog"); + static final Name N_CURRENT_DATABASE = unquotedName("current_database"); + static final Name N_CURRENT_DATE = unquotedName("current_date"); + static final Name N_CURRENT_SCHEMA = unquotedName("current_schema"); + static final Name N_CURRENT_TIME = unquotedName("current_time"); + static final Name N_CURRENT_TIMESTAMP = unquotedName("current_timestamp"); + static final Name N_CURRENT_USER = unquotedName("current_user"); + static final Name N_CURRVAL = unquotedName("currval"); + static final Name N_DATALENGTH = unquotedName("datalength"); + static final Name N_DATEADD = unquotedName("dateadd"); + static final Name N_DATEDIFF = unquotedName("datediff"); + static final Name N_DATEPART = unquotedName("datepart"); + static final Name N_DATE_ADD = unquotedName("date_add"); + static final Name N_DATE_DIFF = unquotedName("date_diff"); + static final Name N_DATE_TRUNC = unquotedName("date_trunc"); + static final Name N_DAYOFWEEK = unquotedName("dayofweek"); + static final Name N_DAYOFYEAR = unquotedName("dayofyear"); + static final Name N_DAYS = unquotedName("days"); + static final Name N_DAYS_BETWEEN = unquotedName("days_between"); + static final Name N_DB_NAME = unquotedName("db_name"); + static final Name N_DECODE = unquotedName("decode"); + static final Name N_DEFAULT = unquotedName("default"); + static final Name N_DEGREES = unquotedName("degrees"); + static final Name N_DELETING = unquotedName("deleting"); + static final Name N_DENSE_RANK = unquotedName("dense_rank"); + static final Name N_DIGITS = unquotedName("digits"); + static final Name N_DUAL = unquotedName("dual"); + static final Name N_E = unquotedName("e"); + static final Name N_EULER = unquotedName("e"); + static final Name N_EVERY = unquotedName("every"); + static final Name N_EXP = unquotedName("exp"); + static final Name N_EXTRACT = unquotedName("extract"); + static final Name N_FIELD = unquotedName("field"); + static final Name N_FLASHBACK = unquotedName("flashback"); + static final Name N_FLOOR = unquotedName("floor"); + static final Name N_FORMAT = unquotedName("format"); + static final Name N_FUNCTION = unquotedName("function"); + static final Name N_GENERATE_ARRAY = unquotedName("generate_array"); + static final Name N_GENERATE_SERIES = unquotedName("generate_series"); + static final Name N_GENERATE_UNIQUE = unquotedName("generate_unique"); + static final Name N_GENERATE_UUID = unquotedName("generate_uuid"); + static final Name N_GENGUID = unquotedName("genguid"); + static final Name N_GEN_ID = unquotedName("gen_id"); + static final Name N_GEN_RANDOM_UUID = unquotedName("gen_random_uuid"); + static final Name N_GEN_UUID = unquotedName("gen_uuid"); + static final Name N_GETDATE = unquotedName("getdate"); + static final Name N_GREATEST = unquotedName("greatest"); + static final Name N_GROUP_CONCAT = unquotedName("group_concat"); + static final Name N_HASHBYTES = unquotedName("hashbytes"); + static final Name N_HASH_MD5 = unquotedName("hash_md5"); + static final Name N_HEX = unquotedName("hex"); + static final Name N_IF = unquotedName("if"); + static final Name N_IFNULL = unquotedName("ifnull"); + static final Name N_IIF = unquotedName("iif"); + static final Name N_INSERT = unquotedName("insert"); + static final Name N_INSERTING = unquotedName("inserting"); + static final Name N_INSTR = unquotedName("instr"); + static final Name N_ISJSON = unquotedName("isjson"); + static final Name N_JOIN = unquotedName("join"); + static final Name N_JSONB_AGG = unquotedName("jsonb_agg"); + static final Name N_JSONB_BUILD_ARRAY = unquotedName("jsonb_build_array"); + static final Name N_JSONB_OBJECT_AGG = unquotedName("jsonb_object_agg"); + static final Name N_JSONB_PATH_EXISTS = unquotedName("jsonb_path_exists"); + static final Name N_JSONB_PATH_QUERY_FIRST = unquotedName("jsonb_path_query_first"); + static final Name N_JSON_AGG = unquotedName("json_agg"); + static final Name N_JSON_ARRAY = unquotedName("json_array"); + static final Name N_JSON_ARRAYAGG = unquotedName("json_arrayagg"); + static final Name N_JSON_BUILD_ARRAY = unquotedName("json_build_array"); + static final Name N_JSON_CONTAINS_PATH = unquotedName("json_contains_path"); + static final Name N_JSON_EXTRACT = unquotedName("json_extract"); + static final Name N_JSON_MERGE = unquotedName("json_merge"); + static final Name N_JSON_MERGE_PRESERVE = unquotedName("json_merge_preserve"); + static final Name N_JSON_OBJECT = unquotedName("json_object"); + static final Name N_JSON_OBJECTAGG = unquotedName("json_objectagg"); + static final Name N_JSON_OBJECT_AGG = unquotedName("json_object_agg"); + static final Name N_JSON_QUOTE = unquotedName("json_quote"); + static final Name N_JSON_TABLE = unquotedName("json_table"); + static final Name N_JSON_VALID = unquotedName("json_valid"); + static final Name N_JSON_VALUE = unquotedName("json_value"); + static final Name N_LCASE = unquotedName("lcase"); + static final Name N_LEAST = unquotedName("least"); + static final Name N_LEFT = unquotedName("left"); + static final Name N_LEN = unquotedName("len"); + static final Name N_LENGTH = unquotedName("length"); + static final Name N_LENGTHB = unquotedName("lengthb"); + static final Name N_LEVEL = unquotedName("level"); + static final Name N_LIST = unquotedName("list"); + static final Name N_LISTAGG = unquotedName("listagg"); + static final Name N_LN = unquotedName("ln"); + static final Name N_LOCATE = unquotedName("locate"); + static final Name N_LOCK_TIMEOUT = unquotedName("lock_timeout"); + static final Name N_LOG = unquotedName("log"); + static final Name N_LOG10 = unquotedName("log10"); + static final Name N_LOGICAL_AND = unquotedName("logical_and"); + static final Name N_LOGICAL_OR = unquotedName("logical_or"); + static final Name N_LOGN = unquotedName("logn"); + static final Name N_LOWER = unquotedName("lower"); + static final Name N_LPAD = unquotedName("lpad"); + static final Name N_LTRIM = unquotedName("ltrim"); + static final Name N_MAP = unquotedName("map"); + static final Name N_MAX = unquotedName("max"); + static final Name N_MAXVALUE = unquotedName("maxvalue"); + static final Name N_MD5 = unquotedName("md5"); + static final Name N_MEDIAN = unquotedName("median"); + static final Name N_MID = unquotedName("mid"); + static final Name N_MIN = unquotedName("min"); + static final Name N_MINVALUE = unquotedName("minvalue"); + static final Name N_MOD = unquotedName("mod"); + static final Name N_MODE = unquotedName("mode"); + static final Name N_MUL = unquotedName("mul"); + static final Name N_NANO100_BETWEEN = unquotedName("nano100_between"); + static final Name N_NEWID = unquotedName("newid"); + static final Name N_NEXTVAL = unquotedName("nextval"); + static final Name N_NOT = unquotedName("not"); + static final Name N_NOW = unquotedName("now"); + static final Name N_NTILE = unquotedName("ntile"); + static final Name N_NULLIF = unquotedName("nullif"); + static final Name N_NVL = unquotedName("nvl"); + static final Name N_NVL2 = unquotedName("nvl2"); + static final Name N_OCTET_LENGTH = unquotedName("octet_length"); + static final Name N_OPENJSON = unquotedName("openjson"); + static final Name N_OPENXML = unquotedName("openxml"); + static final Name N_OREPLACE = unquotedName("oreplace"); + static final Name N_OTRANSLATE = unquotedName("otranslate"); + static final Name N_OVERLAY = unquotedName("overlay"); + static final Name N_PERCENTILE_CONT = unquotedName("percentile_cont"); + static final Name N_PERCENTILE_DISC = unquotedName("percentile_disc"); + static final Name N_PERCENT_RANK = unquotedName("percent_rank"); + static final Name N_PI = unquotedName("pi"); + static final Name N_PIVOT = unquotedName("pivot"); + static final Name N_PLPGSQL = unquotedName("plpgsql"); + static final Name N_POSITION = unquotedName("position"); + static final Name N_POWER = unquotedName("power"); + static final Name N_PRINTF = unquotedName("printf"); + static final Name N_PRIOR = unquotedName("prior"); + static final Name N_PRODUCT = unquotedName("product"); + static final Name N_RADIANS = unquotedName("radians"); + static final Name N_RAND = unquotedName("rand"); + static final Name N_RANDOM = unquotedName("random"); + static final Name N_RANDOMBLOB = unquotedName("randomblob"); + static final Name N_RANDOM_UUID = unquotedName("random_uuid"); + static final Name N_RANK = unquotedName("rank"); + static final Name N_RATIO_TO_REPORT = unquotedName("ratio_to_report"); + static final Name N_RAWTOHEX = unquotedName("rawtohex"); + static final Name N_REGEXP_REPLACE = unquotedName("regexp_replace"); + static final Name N_REGEX_REPLACE = unquotedName("regex_replace"); + static final Name N_REGR_AVGX = unquotedName("regr_avgx"); + static final Name N_REGR_AVGY = unquotedName("regr_avgy"); + static final Name N_REGR_COUNT = unquotedName("regr_count"); + static final Name N_REGR_INTERCEPT = unquotedName("regr_intercept"); + static final Name N_REGR_R2 = unquotedName("regr_r2"); + static final Name N_REGR_SLOPE = unquotedName("regr_slope"); + static final Name N_REGR_SXX = unquotedName("regr_sxx"); + static final Name N_REGR_SXY = unquotedName("regr_sxy"); + static final Name N_REGR_SYY = unquotedName("regr_syy"); + static final Name N_REPEAT = unquotedName("repeat"); + static final Name N_REPLACE = unquotedName("replace"); + static final Name N_REPLICATE = unquotedName("replicate"); + static final Name N_REVERSE = unquotedName("reverse"); + static final Name N_RIGHT = unquotedName("right"); + static final Name N_RND = unquotedName("rnd"); + static final Name N_ROLLUP = unquotedName("rollup"); + static final Name N_ROUND = unquotedName("round"); + static final Name N_ROUND_DOWN = unquotedName("round_down"); + static final Name N_ROW = unquotedName("row"); + static final Name N_ROWNUM = unquotedName("rownum"); + static final Name N_ROWSFROM = unquotedName("rowsfrom"); + static final Name N_ROW_NUMBER = unquotedName("row_number"); + static final Name N_RPAD = unquotedName("rpad"); + static final Name N_RTRIM = unquotedName("rtrim"); + static final Name N_SCHEMA_NAME = unquotedName("schema_name"); + static final Name N_SECONDS_BETWEEN = unquotedName("seconds_between"); + static final Name N_SELECT = unquotedName("select"); + static final Name N_SGN = unquotedName("sgn"); + static final Name N_SIGN = unquotedName("sign"); + static final Name N_SIN = unquotedName("sin"); + static final Name N_SINH = unquotedName("sinh"); + static final Name N_SPACE = unquotedName("space"); + static final Name N_SPLIT = unquotedName("split"); + static final Name N_SPLIT_PART = unquotedName("split_part"); + static final Name N_SQL_TSI_DAY = unquotedName("sql_tsi_day"); + static final Name N_SQL_TSI_FRAC_SECOND = unquotedName("sql_tsi_frac_second"); + static final Name N_SQL_TSI_HOUR = unquotedName("sql_tsi_hour"); + static final Name N_SQL_TSI_MILLI_SECOND = unquotedName("sql_tsi_milli_second"); + static final Name N_SQL_TSI_MINUTE = unquotedName("sql_tsi_minute"); + static final Name N_SQL_TSI_MONTH = unquotedName("sql_tsi_month"); + static final Name N_SQL_TSI_QUARTER = unquotedName("sql_tsi_quarter"); + static final Name N_SQL_TSI_SECOND = unquotedName("sql_tsi_second"); + static final Name N_SQL_TSI_WEEK = unquotedName("sql_tsi_week"); + static final Name N_SQL_TSI_YEAR = unquotedName("sql_tsi_year"); + static final Name N_SQR = unquotedName("sqr"); + static final Name N_SQRT = unquotedName("sqrt"); + static final Name N_SQUARE = unquotedName("square"); + static final Name N_STANDARD_HASH = unquotedName("standard_hash"); + static final Name N_STATS_MODE = unquotedName("stats_mode"); + static final Name N_STDDEV = unquotedName("stddev"); + static final Name N_STDDEV_POP = unquotedName("stddev_pop"); + static final Name N_STDDEV_SAMP = unquotedName("stddev_samp"); + static final Name N_STDEV = unquotedName("stdev"); + static final Name N_STDEVP = unquotedName("stdevp"); + static final Name N_STDEV_SAMP = unquotedName("stdev_samp"); + static final Name N_STRFTIME = unquotedName("strftime"); + static final Name N_STRING_AGG = unquotedName("string_agg"); + static final Name N_STRREVERSE = unquotedName("strreverse"); + static final Name N_STR_REPLACE = unquotedName("str_replace"); + static final Name N_SUBSTR = unquotedName("substr"); + static final Name N_SUBSTRING = unquotedName("substring"); + static final Name N_SUBSTRING_INDEX = unquotedName("substring_index"); + static final Name N_SUM = unquotedName("sum"); + static final Name N_SYSTEM_RANGE = unquotedName("system_range"); + static final Name N_SYSTEM_TIME = unquotedName("system_time"); + static final Name N_SYSUUID = unquotedName("sysuuid"); + static final Name N_SYS_CONNECT_BY_PATH = unquotedName("sys_connect_by_path"); + static final Name N_SYS_GUID = unquotedName("sys_guid"); + static final Name N_T = unquotedName("t"); + static final Name N_TAN = unquotedName("tan"); + static final Name N_TANH = unquotedName("tanh"); + static final Name N_TAU = unquotedName("tau"); + static final Name N_TIMESTAMPADD = unquotedName("timestampadd"); + static final Name N_TIMESTAMPDIFF = unquotedName("timestampdiff"); + static final Name N_TO_CHAR = unquotedName("to_char"); + static final Name N_TO_CLOB = unquotedName("to_clob"); + static final Name N_TO_DATE = unquotedName("to_date"); + static final Name N_TO_HEX = unquotedName("to_hex"); + static final Name N_TO_NUMBER = unquotedName("to_number"); + static final Name N_TO_TIMESTAMP = unquotedName("to_timestamp"); + static final Name N_TRANSLATE = unquotedName("translate"); + static final Name N_TRIM = unquotedName("trim"); + static final Name N_TRUNC = unquotedName("trunc"); + static final Name N_TRUNCATE = unquotedName("truncate"); + static final Name N_TRUNCNUM = unquotedName("truncnum"); + static final Name N_UCASE = unquotedName("ucase"); + static final Name N_UNNEST = unquotedName("unnest"); + static final Name N_UPDATING = unquotedName("updating"); + static final Name N_UPPER = unquotedName("upper"); + static final Name N_USER = unquotedName("user"); + static final Name N_UUID = unquotedName("uuid"); + static final Name N_UUID_GENERATE = unquotedName("uuid_generate"); + static final Name N_UUID_STRING = unquotedName("uuid_string"); + static final Name N_UUID_TO_CHAR = unquotedName("uuid_to_char"); + static final Name N_VALUE = unquotedName("value"); + static final Name N_VALUES = unquotedName("values"); + static final Name N_VAR = unquotedName("var"); + static final Name N_VARIANCE = unquotedName("variance"); + static final Name N_VARIANCE_SAMP = unquotedName("variance_samp"); + static final Name N_VARP = unquotedName("varp"); + static final Name N_VAR_POP = unquotedName("var_pop"); + static final Name N_VAR_SAMP = unquotedName("var_samp"); + static final Name N_WEEKDAY = unquotedName("weekday"); + static final Name N_WIDTH_BUCKET = unquotedName("width_bucket"); + static final Name N_XMLAGG = unquotedName("xmlagg"); + static final Name N_XMLATTRIBUTES = unquotedName("xmlattributes"); + static final Name N_XMLCOMMENT = unquotedName("xmlcomment"); + static final Name N_XMLCONCAT = unquotedName("xmlconcat"); + static final Name N_XMLDOCUMENT = unquotedName("xmldocument"); + static final Name N_XMLELEMENT = unquotedName("xmlelement"); + static final Name N_XMLFOREST = unquotedName("xmlforest"); + static final Name N_XMLPARSE = unquotedName("xmlparse"); + static final Name N_XMLPI = unquotedName("xmlpi"); + static final Name N_XMLQUERY = unquotedName("xmlquery"); + static final Name N_XMLROOT = unquotedName("xmlroot"); + static final Name N_XMLSERIALIZE = unquotedName("xmlserialize"); + static final Name N_XMLTABLE = unquotedName("xmltable"); + static final Name N_XMLTEXT = unquotedName("xmltext"); + static final Name N_XPATH = unquotedName("xpath"); + static final Name N_ZEROBLOB = unquotedName("zeroblob"); diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index 2c77492a58..0b8b16177b 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -323,6 +323,8 @@ import org.jooq.types.Interval; import org.jooq.types.YearToMonth; import org.jooq.types.YearToSecond; +import org.jetbrains.annotations.NotNull; + /** * @author Lukas Eder */ @@ -10192,6 +10194,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext { over = filter = parseJSONArrayAggFunctionIf(); if (filter == null && !basic) over = filter = parseJSONObjectAggFunctionIf(); + if (filter == null) + over = parseCountIfIf(); if (filter == null && over == null) if (!basic) @@ -10831,6 +10835,17 @@ final class DefaultParseContext extends AbstractScope implements ParseContext { return null; } + private final WindowBeforeOverStep parseCountIfIf() { + if (parseFunctionNameIf("COUNTIF", "COUNT_IF")) { + parse('('); + Condition condition = parseCondition(); + parse(')'); + return count().filterWhere(condition); + } + + return null; + } + private final boolean parseSetQuantifier() { boolean distinct = parseKeywordIf("DISTINCT"); if (!distinct) diff --git a/jOOQ/src/main/java/org/jooq/impl/RowCondition.java b/jOOQ/src/main/java/org/jooq/impl/RowCondition.java index ad24951af4..0daaa73bef 100644 --- a/jOOQ/src/main/java/org/jooq/impl/RowCondition.java +++ b/jOOQ/src/main/java/org/jooq/impl/RowCondition.java @@ -47,6 +47,7 @@ import static org.jooq.Comparator.LESS_OR_EQUAL; import static org.jooq.Comparator.NOT_EQUALS; // ... // ... +// ... import static org.jooq.SQLDialect.CUBRID; // ... import static org.jooq.SQLDialect.DERBY; diff --git a/jOOQ/src/main/java/org/jooq/impl/RowOverlapsCondition.java b/jOOQ/src/main/java/org/jooq/impl/RowOverlapsCondition.java index c4e19e5171..606631ee2e 100644 --- a/jOOQ/src/main/java/org/jooq/impl/RowOverlapsCondition.java +++ b/jOOQ/src/main/java/org/jooq/impl/RowOverlapsCondition.java @@ -43,6 +43,7 @@ import static org.jooq.Clause.CONDITION_OVERLAPS; // ... // ... // ... +// ... import static org.jooq.SQLDialect.CUBRID; // ... // ...