From 2ae927a4898fad6b1d2fd497c03a46badcd7f255 Mon Sep 17 00:00:00 2001 From: lukaseder Date: Tue, 9 Aug 2016 18:29:55 +0200 Subject: [PATCH] [#5485] Add createView(String, Function, ? extends String>) where the Function receives Select columns as input --- jOOQ/src/main/java/org/jooq/DSLContext.java | 77 +++++++ .../java/org/jooq/impl/CreateViewImpl.java | 36 +++- jOOQ/src/main/java/org/jooq/impl/DSL.java | 193 +++++++++++++----- .../java/org/jooq/impl/DefaultDSLContext.java | 35 ++++ 4 files changed, 283 insertions(+), 58 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/DSLContext.java b/jOOQ/src/main/java/org/jooq/DSLContext.java index b3ddb687f4..e88210e85a 100644 --- a/jOOQ/src/main/java/org/jooq/DSLContext.java +++ b/jOOQ/src/main/java/org/jooq/DSLContext.java @@ -77,6 +77,7 @@ import java.util.Optional; import java.util.Properties; import java.util.concurrent.CompletionStage; import java.util.concurrent.Executor; +import java.util.function.Function; import java.util.stream.Stream; import javax.annotation.Generated; @@ -7250,6 +7251,44 @@ public interface DSLContext extends Scope , AutoCloseable { @Support CreateViewAsStep createView(Table view, Field... fields); + + /** + * Create a new DSL CREATE VIEW statement. + *

+ * This works like {@link #createView(String, String...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSL#createView(String, String...) + */ + @Support + CreateViewAsStep createView(String view, Function, ? extends String> fieldNameFunction); + + /** + * Create a new DSL CREATE VIEW statement. + *

+ * This works like {@link #createView(Name, Name...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSL#createView(String, String...) + */ + @Support + CreateViewAsStep createView(Name view, Function, ? extends String> fieldNameFunction); + + /** + * Create a new DSL CREATE VIEW statement. + *

+ * This works like {@link #createView(Table, Field...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSL#createView(String, String...) + */ + @Support + CreateViewAsStep createView(Table view, Function, ? extends String> fieldNameFunction); + + /** * Create a new DSL CREATE VIEW statement. * @@ -7274,6 +7313,44 @@ public interface DSLContext extends Scope , AutoCloseable { @Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) CreateViewAsStep createViewIfNotExists(Table view, Field... fields); + + /** + * Create a new DSL CREATE VIEW statement. + *

+ * This works like {@link #createViewIfNotExists(String, String...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSL#createViewIfNotExists(String, String...) + */ + @Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) + CreateViewAsStep createViewIfNotExists(String view, Function, ? extends String> fieldNameFunction); + + /** + * Create a new DSL CREATE VIEW statement. + *

+ * This works like {@link #createViewIfNotExists(Name, Name...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSL#createViewIfNotExists(String, String...) + */ + @Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) + CreateViewAsStep createViewIfNotExists(Name view, Function, ? extends String> fieldNameFunction); + + /** + * Create a new DSL CREATE VIEW statement. + *

+ * This works like {@link #createViewIfNotExists(Table, Field...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSL#createViewIfNotExists(String, String...) + */ + @Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) + CreateViewAsStep createViewIfNotExists(Table view, Function, ? extends String> fieldNameFunction); + + /** * Create a new DSL CREATE INDEX statement. * diff --git a/jOOQ/src/main/java/org/jooq/impl/CreateViewImpl.java b/jOOQ/src/main/java/org/jooq/impl/CreateViewImpl.java index 0d52a1a5a1..9252a934db 100644 --- a/jOOQ/src/main/java/org/jooq/impl/CreateViewImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/CreateViewImpl.java @@ -54,9 +54,13 @@ import static org.jooq.SQLDialect.FIREBIRD; import static org.jooq.SQLDialect.SQLITE; // ... import static org.jooq.conf.ParamType.INLINED; +import static org.jooq.impl.DSL.field; +import static org.jooq.impl.DSL.name; import static org.jooq.impl.DSL.selectFrom; import static org.jooq.impl.DSL.table; +import java.util.function.Function; + import org.jooq.Clause; import org.jooq.Configuration; import org.jooq.Context; @@ -81,19 +85,30 @@ final class CreateViewImpl extends AbstractQuery implements /** * Generated UID */ - private static final long serialVersionUID = 8904572826501186329L; - private static final Clause[] CLAUSES = { CREATE_VIEW }; + private static final long serialVersionUID = 8904572826501186329L; + private static final Clause[] CLAUSES = { CREATE_VIEW }; - private final boolean ifNotExists; - private final Table view; - private final Field[] fields; - private Select select; + private final boolean ifNotExists; + private final Table view; + private final Function, ? extends String> fieldNameFunction; + private Field[] fields; + private Select select; CreateViewImpl(Configuration configuration, Table view, Field[] fields, boolean ifNotExists) { super(configuration); this.view = view; this.fields = fields; + this.fieldNameFunction = null; + this.ifNotExists = ifNotExists; + } + + CreateViewImpl(Configuration configuration, Table view, Function, ? extends String> fieldNameFunction, boolean ifNotExists) { + super(configuration); + + this.view = view; + this.fields = null; + this.fieldNameFunction = fieldNameFunction; this.ifNotExists = ifNotExists; } @@ -104,6 +119,15 @@ final class CreateViewImpl extends AbstractQuery implements @Override public final CreateViewFinalStep as(Select s) { this.select = s; + + + if (fieldNameFunction != null) + fields = s.getSelect() + .stream() + .map(f -> field(name(fieldNameFunction.apply(f)), f.getDataType())) + .toArray(Field[]::new); + + return this; } diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index f9ea6289fb..e4e3696042 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -95,6 +95,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.UUID; +import java.util.function.Function; import javax.annotation.Generated; import javax.sql.DataSource; @@ -5500,6 +5501,50 @@ public class DSL { return using(new DefaultConfiguration()).createView(view, fields); } + + /** + * Create a new DSL CREATE VIEW statement. + *

+ * This works like {@link #createView(Table, Field...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSLContext#createView(String, String...) + */ + @Support + public static CreateViewAsStep createView(String view, Function, ? extends String> fieldNameFunction) { + return using(new DefaultConfiguration()).createView(view, fieldNameFunction); + } + + /** + * Create a new DSL CREATE VIEW statement. + *

+ * This works like {@link #createView(Table, Field...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSLContext#createView(Name, Name...) + */ + @Support + public static CreateViewAsStep createView(Name view, Function, ? extends String> fieldNameFunction) { + return using(new DefaultConfiguration()).createView(view, fieldNameFunction); + } + + /** + * Create a new DSL CREATE VIEW statement. + *

+ * This works like {@link #createView(Table, Field...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSLContext#createView(Table, Field...) + */ + @Support + public static CreateViewAsStep createView(Table view, Function, ? extends String> fieldNameFunction) { + return using(new DefaultConfiguration()).createView(view, fieldNameFunction); + } + + /** * Create a new DSL CREATE VIEW IF NOT EXISTS statement. * @@ -5530,6 +5575,50 @@ public class DSL { return using(new DefaultConfiguration()).createViewIfNotExists(view, fields); } + + /** + * Create a new DSL CREATE VIEW IF NOT EXISTS statement. + *

+ * This works like {@link #createViewIfNotExists(String, String...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSLContext#createViewIfNotExists(String, String...) + */ + @Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) + public static CreateViewAsStep createViewIfNotExists(String view, Function, ? extends String> fieldNameFunction) { + return using(new DefaultConfiguration()).createViewIfNotExists(view, fieldNameFunction); + } + + /** + * Create a new DSL CREATE VIEW IF NOT EXISTS statement. + *

+ * This works like {@link #createViewIfNotExists(Name, Name...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSLContext#createViewIfNotExists(Name, Name...) + */ + @Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) + public static CreateViewAsStep createViewIfNotExists(Name view, Function, ? extends String> fieldNameFunction) { + return using(new DefaultConfiguration()).createViewIfNotExists(view, fieldNameFunction); + } + + /** + * Create a new DSL CREATE VIEW IF NOT EXISTS statement. + *

+ * This works like {@link #createViewIfNotExists(Table, Field...)} except that the + * view's field names are derived from the view's {@link Select} statement + * using a function. + * + * @see DSLContext#createViewIfNotExists(Table, Field...) + */ + @Support({ FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) + public static CreateViewAsStep createViewIfNotExists(Table view, Function, ? extends String> fieldNameFunction) { + return using(new DefaultConfiguration()).createViewIfNotExists(view, fieldNameFunction); + } + + /** * Create a new DSL CREATE INDEX statement. * @@ -6648,7 +6737,7 @@ public class DSL { // The field is an actual CURSOR or REF CURSOR returned from a stored // procedure or from a NESTED TABLE else if (cursor.getType() == Result.class) { - return new FunctionTable(cursor); + return new org.jooq.impl.FunctionTable(cursor); } @@ -8532,7 +8621,7 @@ public class DSL { @Support @PlainSQL public static Field function(String name, DataType type, Field... arguments) { - return new Function(name, type, nullSafe(arguments)); + return new org.jooq.impl.Function(name, type, nullSafe(arguments)); } /** @@ -8558,7 +8647,7 @@ public class DSL { */ @Support public static Field function(Name name, DataType type, Field... arguments) { - return new Function(name, type, nullSafe(arguments)); + return new org.jooq.impl.Function(name, type, nullSafe(arguments)); } /** @@ -11180,7 +11269,7 @@ public class DSL { */ @Support public static Field charLength(Field field) { - return new Function(Term.CHAR_LENGTH, SQLDataType.INTEGER, nullSafe(field)); + return new org.jooq.impl.Function(Term.CHAR_LENGTH, SQLDataType.INTEGER, nullSafe(field)); } /** @@ -11200,7 +11289,7 @@ public class DSL { */ @Support public static Field bitLength(Field field) { - return new Function(Term.BIT_LENGTH, SQLDataType.INTEGER, nullSafe(field)); + return new org.jooq.impl.Function(Term.BIT_LENGTH, SQLDataType.INTEGER, nullSafe(field)); } /** @@ -11220,7 +11309,7 @@ public class DSL { */ @Support public static Field octetLength(Field field) { - return new Function(Term.OCTET_LENGTH, SQLDataType.INTEGER, nullSafe(field)); + return new org.jooq.impl.Function(Term.OCTET_LENGTH, SQLDataType.INTEGER, nullSafe(field)); } // ------------------------------------------------------------------------ @@ -12148,7 +12237,7 @@ public class DSL { array[i] = new WrappedList(new QueryPartList>(fieldSets[i])); } - return new Function("grouping sets", SQLDataType.OTHER, array); + return new org.jooq.impl.Function("grouping sets", SQLDataType.OTHER, array); } /** @@ -13163,7 +13252,7 @@ public class DSL { */ @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) public static Field atan2(Field x, Field y) { - return new Function(Term.ATAN2, SQLDataType.NUMERIC, nullSafe(x), nullSafe(y)); + return new org.jooq.impl.Function(Term.ATAN2, SQLDataType.NUMERIC, nullSafe(x), nullSafe(y)); } /** @@ -13464,7 +13553,7 @@ public class DSL { */ @Support public static AggregateFunction count() { - return count(Function.ASTERISK); + return count(org.jooq.impl.Function.ASTERISK); } /** @@ -13472,7 +13561,7 @@ public class DSL { */ @Support public static AggregateFunction count(Field field) { - return new Function("count", SQLDataType.INTEGER, nullSafe(field)); + return new org.jooq.impl.Function("count", SQLDataType.INTEGER, nullSafe(field)); } /** @@ -13492,7 +13581,7 @@ public class DSL { */ @Support({ CUBRID, DERBY, H2, HSQLDB, FIREBIRD, MARIADB, MYSQL, POSTGRES, SQLITE }) public static AggregateFunction countDistinct(Field field) { - return new Function("count", true, SQLDataType.INTEGER, nullSafe(field)); + return new org.jooq.impl.Function("count", true, SQLDataType.INTEGER, nullSafe(field)); } /** @@ -13518,7 +13607,7 @@ public class DSL { */ @Support({ HSQLDB, MYSQL, POSTGRES }) public static AggregateFunction countDistinct(Field... fields) { - return new Function("count", true, SQLDataType.INTEGER, nullSafe(fields)); + return new org.jooq.impl.Function("count", true, SQLDataType.INTEGER, nullSafe(fields)); } /** @@ -13578,7 +13667,7 @@ public class DSL { */ @Support({ HSQLDB, POSTGRES }) public static ArrayAggOrderByStep arrayAgg(Field field) { - return new Function(Term.ARRAY_AGG, field.getDataType().getArrayDataType(), nullSafe(field)); + return new org.jooq.impl.Function(Term.ARRAY_AGG, field.getDataType().getArrayDataType(), nullSafe(field)); } @@ -13726,7 +13815,7 @@ public class DSL { */ @Support public static AggregateFunction max(Field field) { - return new Function("max", nullSafeDataType(field), nullSafe(field)); + return new org.jooq.impl.Function("max", nullSafeDataType(field), nullSafe(field)); } /** @@ -13734,7 +13823,7 @@ public class DSL { */ @Support public static AggregateFunction maxDistinct(Field field) { - return new Function("max", true, nullSafeDataType(field), nullSafe(field)); + return new org.jooq.impl.Function("max", true, nullSafeDataType(field), nullSafe(field)); } /** @@ -13742,7 +13831,7 @@ public class DSL { */ @Support public static AggregateFunction min(Field field) { - return new Function("min", nullSafeDataType(field), nullSafe(field)); + return new org.jooq.impl.Function("min", nullSafeDataType(field), nullSafe(field)); } /** @@ -13750,7 +13839,7 @@ public class DSL { */ @Support public static AggregateFunction minDistinct(Field field) { - return new Function("min", true, nullSafeDataType(field), nullSafe(field)); + return new org.jooq.impl.Function("min", true, nullSafeDataType(field), nullSafe(field)); } /** @@ -13758,7 +13847,7 @@ public class DSL { */ @Support public static AggregateFunction sum(Field field) { - return new Function("sum", SQLDataType.NUMERIC, nullSafe(field)); + return new org.jooq.impl.Function("sum", SQLDataType.NUMERIC, nullSafe(field)); } /** @@ -13766,7 +13855,7 @@ public class DSL { */ @Support public static AggregateFunction sumDistinct(Field field) { - return new Function("sum", true, SQLDataType.NUMERIC, nullSafe(field)); + return new org.jooq.impl.Function("sum", true, SQLDataType.NUMERIC, nullSafe(field)); } /** @@ -13774,7 +13863,7 @@ public class DSL { */ @Support public static AggregateFunction avg(Field field) { - return new Function("avg", SQLDataType.NUMERIC, nullSafe(field)); + return new org.jooq.impl.Function("avg", SQLDataType.NUMERIC, nullSafe(field)); } /** @@ -13782,7 +13871,7 @@ public class DSL { */ @Support public static AggregateFunction avgDistinct(Field field) { - return new Function("avg", true, SQLDataType.NUMERIC, nullSafe(field)); + return new org.jooq.impl.Function("avg", true, SQLDataType.NUMERIC, nullSafe(field)); } /** @@ -13790,7 +13879,7 @@ public class DSL { */ @Support({ CUBRID, HSQLDB, POSTGRES_9_4 }) public static AggregateFunction median(Field field) { - return new Function(Term.MEDIAN, SQLDataType.NUMERIC, nullSafe(field)); + return new org.jooq.impl.Function(Term.MEDIAN, SQLDataType.NUMERIC, nullSafe(field)); } /** @@ -13798,7 +13887,7 @@ public class DSL { */ @Support({ CUBRID, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) public static AggregateFunction stddevPop(Field field) { - return new Function(Term.STDDEV_POP, SQLDataType.NUMERIC, nullSafe(field)); + return new org.jooq.impl.Function(Term.STDDEV_POP, SQLDataType.NUMERIC, nullSafe(field)); } /** @@ -13806,7 +13895,7 @@ public class DSL { */ @Support({ CUBRID, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) public static AggregateFunction stddevSamp(Field field) { - return new Function(Term.STDDEV_SAMP, SQLDataType.NUMERIC, nullSafe(field)); + return new org.jooq.impl.Function(Term.STDDEV_SAMP, SQLDataType.NUMERIC, nullSafe(field)); } /** @@ -13814,7 +13903,7 @@ public class DSL { */ @Support({ CUBRID, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) public static AggregateFunction varPop(Field field) { - return new Function(Term.VAR_POP, SQLDataType.NUMERIC, nullSafe(field)); + return new org.jooq.impl.Function(Term.VAR_POP, SQLDataType.NUMERIC, nullSafe(field)); } /** @@ -13822,7 +13911,7 @@ public class DSL { */ @Support({ CUBRID, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) public static AggregateFunction varSamp(Field field) { - return new Function(Term.VAR_SAMP, SQLDataType.NUMERIC, nullSafe(field)); + return new org.jooq.impl.Function(Term.VAR_SAMP, SQLDataType.NUMERIC, nullSafe(field)); } /** @@ -13837,7 +13926,7 @@ public class DSL { */ @Support({ POSTGRES }) public static AggregateFunction regrSlope(Field y, Field x) { - return new Function("regr_slope", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); + return new org.jooq.impl.Function("regr_slope", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); } /** @@ -13852,7 +13941,7 @@ public class DSL { */ @Support({ POSTGRES }) public static AggregateFunction regrIntercept(Field y, Field x) { - return new Function("regr_intercept", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); + return new org.jooq.impl.Function("regr_intercept", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); } /** @@ -13867,7 +13956,7 @@ public class DSL { */ @Support({ POSTGRES }) public static AggregateFunction regrCount(Field y, Field x) { - return new Function("regr_count", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); + return new org.jooq.impl.Function("regr_count", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); } /** @@ -13882,7 +13971,7 @@ public class DSL { */ @Support({ POSTGRES }) public static AggregateFunction regrR2(Field y, Field x) { - return new Function("regr_r2", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); + return new org.jooq.impl.Function("regr_r2", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); } /** @@ -13897,7 +13986,7 @@ public class DSL { */ @Support({ POSTGRES }) public static AggregateFunction regrAvgX(Field y, Field x) { - return new Function("regr_avgx", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); + return new org.jooq.impl.Function("regr_avgx", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); } /** @@ -13912,7 +14001,7 @@ public class DSL { */ @Support({ POSTGRES }) public static AggregateFunction regrAvgY(Field y, Field x) { - return new Function("regr_avgy", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); + return new org.jooq.impl.Function("regr_avgy", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); } /** @@ -13927,7 +14016,7 @@ public class DSL { */ @Support({ POSTGRES }) public static AggregateFunction regrSXX(Field y, Field x) { - return new Function("regr_sxx", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); + return new org.jooq.impl.Function("regr_sxx", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); } /** @@ -13942,7 +14031,7 @@ public class DSL { */ @Support({ POSTGRES }) public static AggregateFunction regrSYY(Field y, Field x) { - return new Function("regr_syy", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); + return new org.jooq.impl.Function("regr_syy", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); } /** @@ -13957,7 +14046,7 @@ public class DSL { */ @Support({ POSTGRES }) public static AggregateFunction regrSXY(Field y, Field x) { - return new Function("regr_sxy", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); + return new org.jooq.impl.Function("regr_sxy", SQLDataType.NUMERIC, nullSafe(y), nullSafe(x)); } /** @@ -13979,7 +14068,7 @@ public class DSL { */ @Support({ CUBRID, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) public static OrderedAggregateFunction listAgg(Field field) { - return new Function(Term.LIST_AGG, SQLDataType.VARCHAR, nullSafe(field)); + return new org.jooq.impl.Function(Term.LIST_AGG, SQLDataType.VARCHAR, nullSafe(field)); } /** @@ -14001,7 +14090,7 @@ public class DSL { */ @Support({ CUBRID, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) public static OrderedAggregateFunction listAgg(Field field, String separator) { - return new Function(Term.LIST_AGG, SQLDataType.VARCHAR, nullSafe(field), inline(separator)); + return new org.jooq.impl.Function(Term.LIST_AGG, SQLDataType.VARCHAR, nullSafe(field), inline(separator)); } /** @@ -14101,7 +14190,7 @@ public class DSL { */ @Support({ POSTGRES_9_4 }) public static OrderedAggregateFunction rank(Field... fields) { - return new Function("rank", SQLDataType.INTEGER, fields); + return new org.jooq.impl.Function("rank", SQLDataType.INTEGER, fields); } /** @@ -14110,7 +14199,7 @@ public class DSL { */ @Support({ POSTGRES_9_4 }) public static OrderedAggregateFunction denseRank(Field... fields) { - return new Function("dense_rank", SQLDataType.INTEGER, fields); + return new org.jooq.impl.Function("dense_rank", SQLDataType.INTEGER, fields); } /** @@ -14119,7 +14208,7 @@ public class DSL { */ @Support({ POSTGRES_9_4 }) public static OrderedAggregateFunction percentRank(Field... fields) { - return new Function("percent_rank", SQLDataType.INTEGER, fields); + return new org.jooq.impl.Function("percent_rank", SQLDataType.INTEGER, fields); } /** @@ -14128,7 +14217,7 @@ public class DSL { */ @Support({ POSTGRES_9_4 }) public static OrderedAggregateFunction cumeDist(Field... fields) { - return new Function("cume_dist", SQLDataType.NUMERIC, fields); + return new org.jooq.impl.Function("cume_dist", SQLDataType.NUMERIC, fields); } /** @@ -14156,7 +14245,7 @@ public class DSL { */ @Support({ POSTGRES_9_4 }) public static OrderedAggregateFunction percentileCont(Field field) { - return new Function("percentile_cont", SQLDataType.NUMERIC, nullSafe(field)); + return new org.jooq.impl.Function("percentile_cont", SQLDataType.NUMERIC, nullSafe(field)); } /** @@ -14184,7 +14273,7 @@ public class DSL { */ @Support({ POSTGRES_9_4 }) public static OrderedAggregateFunction percentileDisc(Field field) { - return new Function("percentile_disc", SQLDataType.NUMERIC, nullSafe(field)); + return new org.jooq.impl.Function("percentile_disc", SQLDataType.NUMERIC, nullSafe(field)); } // ------------------------------------------------------------------------- @@ -14406,7 +14495,7 @@ public class DSL { */ @Support({ CUBRID, DERBY, FIREBIRD_3_0, H2, HSQLDB, POSTGRES }) public static WindowOverStep rowNumber() { - return new Function(ROW_NUMBER, SQLDataType.INTEGER); + return new org.jooq.impl.Function(ROW_NUMBER, SQLDataType.INTEGER); } /** @@ -14414,7 +14503,7 @@ public class DSL { */ @Support({ CUBRID, FIREBIRD_3_0, POSTGRES }) public static WindowOverStep rank() { - return new Function("rank", SQLDataType.INTEGER); + return new org.jooq.impl.Function("rank", SQLDataType.INTEGER); } /** @@ -14422,7 +14511,7 @@ public class DSL { */ @Support({ CUBRID, FIREBIRD_3_0, POSTGRES }) public static WindowOverStep denseRank() { - return new Function("dense_rank", SQLDataType.INTEGER); + return new org.jooq.impl.Function("dense_rank", SQLDataType.INTEGER); } /** @@ -14430,7 +14519,7 @@ public class DSL { */ @Support({ CUBRID, POSTGRES }) public static WindowOverStep percentRank() { - return new Function("percent_rank", SQLDataType.NUMERIC); + return new org.jooq.impl.Function("percent_rank", SQLDataType.NUMERIC); } /** @@ -14438,7 +14527,7 @@ public class DSL { */ @Support({ CUBRID, POSTGRES }) public static WindowOverStep cumeDist() { - return new Function("cume_dist", SQLDataType.NUMERIC); + return new org.jooq.impl.Function("cume_dist", SQLDataType.NUMERIC); } /** @@ -14446,7 +14535,7 @@ public class DSL { */ @Support({ CUBRID, POSTGRES }) public static WindowOverStep ntile(int number) { - return new Function("ntile", SQLDataType.INTEGER, inline(number)); + return new org.jooq.impl.Function("ntile", SQLDataType.INTEGER, inline(number)); } /** @@ -14470,7 +14559,7 @@ public class DSL { */ @Support({ CUBRID, FIREBIRD_3_0, POSTGRES }) public static WindowIgnoreNullsStep firstValue(Field field) { - return new Function("first_value", nullSafeDataType(field), nullSafe(field)); + return new org.jooq.impl.Function("first_value", nullSafeDataType(field), nullSafe(field)); } /** @@ -14478,7 +14567,7 @@ public class DSL { */ @Support({ CUBRID, FIREBIRD_3_0, POSTGRES }) public static WindowIgnoreNullsStep lastValue(Field field) { - return new Function("last_value", nullSafeDataType(field), nullSafe(field)); + return new org.jooq.impl.Function("last_value", nullSafeDataType(field), nullSafe(field)); } /** @@ -14494,7 +14583,7 @@ public class DSL { */ @Support({ FIREBIRD_3_0, POSTGRES }) public static WindowIgnoreNullsStep nthValue(Field field, Field nth) { - return new Function("nth_value", nullSafeDataType(field), nullSafe(field), nullSafe(nth)); + return new org.jooq.impl.Function("nth_value", nullSafeDataType(field), nullSafe(field), nullSafe(nth)); } /** diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java index 872eeab549..1ea602e796 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java @@ -78,6 +78,7 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.Executor; +import java.util.function.Function; import java.util.stream.Stream; import javax.annotation.Generated; @@ -2491,6 +2492,23 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri return new CreateViewImpl(configuration(), view, fields, false); } + + @Override + public CreateViewAsStep createView(String view, Function, ? extends String> fieldNameFunction) { + return createView(table(name(view)), fieldNameFunction); + } + + @Override + public CreateViewAsStep createView(Name view, Function, ? extends String> fieldNameFunction) { + return createView(table(view), fieldNameFunction); + } + + @Override + public CreateViewAsStep createView(Table view, Function, ? extends String> fieldNameFunction) { + return new CreateViewImpl(configuration(), view, fieldNameFunction, false); + } + + @Override public CreateViewAsStep createViewIfNotExists(String view, String... fields) { return createViewIfNotExists(table(name(view)), Tools.fieldsByName(view, fields)); @@ -2506,6 +2524,23 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri return new CreateViewImpl(configuration(), view, fields, true); } + + @Override + public CreateViewAsStep createViewIfNotExists(String view, Function, ? extends String> fieldNameFunction) { + return createView(table(name(view)), fieldNameFunction); + } + + @Override + public CreateViewAsStep createViewIfNotExists(Name view, Function, ? extends String> fieldNameFunction) { + return createView(table(view), fieldNameFunction); + } + + @Override + public CreateViewAsStep createViewIfNotExists(Table view, Function, ? extends String> fieldNameFunction) { + return new CreateViewImpl(configuration(), view, fieldNameFunction, true); + } + + @Override public CreateSchemaFinalStep createSchema(String schema) { return createSchema(name(schema));