From 887518ee241f59c74ced2b088b6d0c7d50d14714 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Mon, 21 Jun 2021 11:32:33 +0200 Subject: [PATCH] [jOOQ/jOOQ#12028] Add MULTISET_AGG aggregate and window function support --- .../src/main/java/org/jooq/conf/Settings.java | 84 +- .../jooq/impl/AbstractAggregateFunction.java | 10 + .../src/main/java/org/jooq/impl/ArrayAgg.java | 1 - jOOQ/src/main/java/org/jooq/impl/DSL.java | 1303 +++++++++++++++++ .../main/java/org/jooq/impl/MultisetAgg.java | 128 ++ .../java/org/jooq/impl/MultisetDataType.java | 4 - jOOQ/src/main/java/org/jooq/impl/Names.java | 1 + .../main/java/org/jooq/impl/ParserImpl.java | 20 + .../resources/xsd/jooq-runtime-3.15.0.xsd | 10 +- 9 files changed, 1466 insertions(+), 95 deletions(-) create mode 100644 jOOQ/src/main/java/org/jooq/impl/MultisetAgg.java diff --git a/jOOQ/src/main/java/org/jooq/conf/Settings.java b/jOOQ/src/main/java/org/jooq/conf/Settings.java index dce364c625..ccdb7a1f79 100644 --- a/jOOQ/src/main/java/org/jooq/conf/Settings.java +++ b/jOOQ/src/main/java/org/jooq/conf/Settings.java @@ -244,13 +244,7 @@ public class Settings protected Boolean emulateOnDuplicateKeyUpdateOnPrimaryKeyOnly = false; @XmlElement(defaultValue = "DEFAULT") @XmlSchemaType(name = "string") - protected NestedCollectionEmulation emulateList = NestedCollectionEmulation.DEFAULT; - @XmlElement(defaultValue = "DEFAULT") - @XmlSchemaType(name = "string") protected NestedCollectionEmulation emulateMultiset = NestedCollectionEmulation.DEFAULT; - @XmlElement(defaultValue = "DEFAULT") - @XmlSchemaType(name = "string") - protected NestedCollectionEmulation emulateSet = NestedCollectionEmulation.DEFAULT; @XmlElement(defaultValue = "LOG_DEBUG") @XmlSchemaType(name = "string") protected ExecuteWithoutWhere executeUpdateWithoutWhere = ExecuteWithoutWhere.LOG_DEBUG; @@ -2281,23 +2275,7 @@ public class Settings } /** - * [#3884] Whether LIST support should be emulated. - * - */ - public NestedCollectionEmulation getEmulateList() { - return emulateList; - } - - /** - * [#3884] Whether LIST support should be emulated. - * - */ - public void setEmulateList(NestedCollectionEmulation value) { - this.emulateList = value; - } - - /** - * [#3884] Whether MULTISET support should be emulated. + * [#3884] How MULTISET support should be emulated. * */ public NestedCollectionEmulation getEmulateMultiset() { @@ -2305,29 +2283,13 @@ public class Settings } /** - * [#3884] Whether MULTISET support should be emulated. + * [#3884] How MULTISET support should be emulated. * */ public void setEmulateMultiset(NestedCollectionEmulation value) { this.emulateMultiset = value; } - /** - * [#3884] Whether SET support should be emulated. - * - */ - public NestedCollectionEmulation getEmulateSet() { - return emulateSet; - } - - /** - * [#3884] Whether SET support should be emulated. - * - */ - public void setEmulateSet(NestedCollectionEmulation value) { - this.emulateSet = value; - } - /** * [#6771] Specifies whether UPDATE statements are allowed to be executed lacking a WHERE clause. This has no effect on rendering the statements SQL string. * @@ -3676,16 +3638,7 @@ public class Settings } /** - * [#3884] Whether LIST support should be emulated. - * - */ - public Settings withEmulateList(NestedCollectionEmulation value) { - setEmulateList(value); - return this; - } - - /** - * [#3884] Whether MULTISET support should be emulated. + * [#3884] How MULTISET support should be emulated. * */ public Settings withEmulateMultiset(NestedCollectionEmulation value) { @@ -3693,15 +3646,6 @@ public class Settings return this; } - /** - * [#3884] Whether SET support should be emulated. - * - */ - public Settings withEmulateSet(NestedCollectionEmulation value) { - setEmulateSet(value); - return this; - } - /** * [#6771] Specifies whether UPDATE statements are allowed to be executed lacking a WHERE clause. This has no effect on rendering the statements SQL string. * @@ -4090,9 +4034,7 @@ public class Settings builder.append("inListPadBase", inListPadBase); builder.append("delimiter", delimiter); builder.append("emulateOnDuplicateKeyUpdateOnPrimaryKeyOnly", emulateOnDuplicateKeyUpdateOnPrimaryKeyOnly); - builder.append("emulateList", emulateList); builder.append("emulateMultiset", emulateMultiset); - builder.append("emulateSet", emulateSet); builder.append("executeUpdateWithoutWhere", executeUpdateWithoutWhere); builder.append("executeDeleteWithoutWhere", executeDeleteWithoutWhere); builder.append("interpreterDialect", interpreterDialect); @@ -4921,15 +4863,6 @@ public class Settings return false; } } - if (emulateList == null) { - if (other.emulateList!= null) { - return false; - } - } else { - if (!emulateList.equals(other.emulateList)) { - return false; - } - } if (emulateMultiset == null) { if (other.emulateMultiset!= null) { return false; @@ -4939,15 +4872,6 @@ public class Settings return false; } } - if (emulateSet == null) { - if (other.emulateSet!= null) { - return false; - } - } else { - if (!emulateSet.equals(other.emulateSet)) { - return false; - } - } if (executeUpdateWithoutWhere == null) { if (other.executeUpdateWithoutWhere!= null) { return false; @@ -5338,9 +5262,7 @@ public class Settings result = ((prime*result)+((inListPadBase == null)? 0 :inListPadBase.hashCode())); result = ((prime*result)+((delimiter == null)? 0 :delimiter.hashCode())); result = ((prime*result)+((emulateOnDuplicateKeyUpdateOnPrimaryKeyOnly == null)? 0 :emulateOnDuplicateKeyUpdateOnPrimaryKeyOnly.hashCode())); - result = ((prime*result)+((emulateList == null)? 0 :emulateList.hashCode())); result = ((prime*result)+((emulateMultiset == null)? 0 :emulateMultiset.hashCode())); - result = ((prime*result)+((emulateSet == null)? 0 :emulateSet.hashCode())); result = ((prime*result)+((executeUpdateWithoutWhere == null)? 0 :executeUpdateWithoutWhere.hashCode())); result = ((prime*result)+((executeDeleteWithoutWhere == null)? 0 :executeDeleteWithoutWhere.hashCode())); result = ((prime*result)+((interpreterDialect == null)? 0 :interpreterDialect.hashCode())); diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java b/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java index 712dead3df..5f09cdd810 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractAggregateFunction.java @@ -60,6 +60,7 @@ import static org.jooq.impl.QueryPartCollectionView.wrap; import static org.jooq.impl.SQLDataType.DOUBLE; import static org.jooq.impl.SQLDataType.NUMERIC; import static org.jooq.impl.Tools.camelCase; +import static org.jooq.impl.Tools.isEmpty; import java.util.Arrays; import java.util.Collection; @@ -369,6 +370,15 @@ implements return DSL.nullif(fo(function), (Field) zero()); } + /** + * Apply this aggregate function's ORDER BY, + * FILTER and OVER clauses to an argument + * aggregate function. + */ + final Field ofo(AbstractAggregateFunction function) { + return fo(isEmpty(withinGroupOrderBy) ? function : function.orderBy(withinGroupOrderBy)); + } + /** * Apply this aggregate function's FILTER and OVER * clauses to an argument aggregate function. diff --git a/jOOQ/src/main/java/org/jooq/impl/ArrayAgg.java b/jOOQ/src/main/java/org/jooq/impl/ArrayAgg.java index 5bb2c98f77..576ed84664 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ArrayAgg.java +++ b/jOOQ/src/main/java/org/jooq/impl/ArrayAgg.java @@ -37,7 +37,6 @@ */ package org.jooq.impl; -// ... import static org.jooq.impl.Names.N_ARRAY_AGG; import org.jooq.Context; diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index 3bc47a19f6..a65f9a03f4 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -23683,6 +23683,9 @@ public class DSL { * transparently. * *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

* A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. * An important known limitation is that predicates based on @@ -23878,6 +23881,1306 @@ public class DSL { return new ArrayAgg(true, Tools.nullSafe(field)); } + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep> multisetAgg(Collection> fields) { + return new MultisetAgg<>(false, row(fields)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep> multisetAgg(Field... fields) { + return new MultisetAgg<>(false, row(fields)); + } + + + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1) { + return new MultisetAgg<>(false, row(field1)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2) { + return new MultisetAgg<>(false, row(field1, field2)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3) { + return new MultisetAgg<>(false, row(field1, field2, field3)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11, SelectField field12) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11, SelectField field12, SelectField field13) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11, SelectField field12, SelectField field13, SelectField field14) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11, SelectField field12, SelectField field13, SelectField field14, SelectField field15) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11, SelectField field12, SelectField field13, SelectField field14, SelectField field15, SelectField field16) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11, SelectField field12, SelectField field13, SelectField field14, SelectField field15, SelectField field16, SelectField field17) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11, SelectField field12, SelectField field13, SelectField field14, SelectField field15, SelectField field16, SelectField field17, SelectField field18) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11, SelectField field12, SelectField field13, SelectField field14, SelectField field15, SelectField field16, SelectField field17, SelectField field18, SelectField field19) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11, SelectField field12, SelectField field13, SelectField field14, SelectField field15, SelectField field16, SelectField field17, SelectField field18, SelectField field19, SelectField field20) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11, SelectField field12, SelectField field13, SelectField field14, SelectField field15, SelectField field16, SelectField field17, SelectField field18, SelectField field19, SelectField field20, SelectField field21) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21)); + } + + /** + * Get the MULTISET_AGG aggregate function to nest group + * contents. + *

+ * EXPERIMENTAL: This synthetic, non-standard aggregate function works in a + * similar way as the standard SQL ARRAY_AGG aggregate + * function. It is emulated using mappings to any of: + *

+ *

    + *
  • {@link NestedCollectionEmulation#JSON}: A MULTISET of ROW types works + * just like a {@link #jsonArrayAgg(Field)} of + * {@link #jsonObject(Field...)}, or an application of + * {@link SelectForStep#forJSON()}. jOOQ produces a JSON encoding that is + * compatible with {@link DSLContext#fetchFromJSON(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link JSONFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#JSONB}: Just like JSON, + * but we're using {@link #jsonbArrayAgg(Field)} and + * {@link #jsonbObject(Field...)}, or {@link SelectForStep#forJSONB()}.
  • + *
  • {@link NestedCollectionEmulation#XML}: A MULTISET of ROW types works + * just like a {@link #xmlagg(Field)} of + * {@link #xmlelement(Name, Field...)}, or an application of + * {@link SelectForStep#forXML()}. jOOQ produces an XML encoding that is + * compatible with {@link DSLContext#fetchFromXML(String)}. Future jOOQ + * versions will make this format configurable according to + * {@link XMLFormat.RecordFormat}.
  • + *
  • {@link NestedCollectionEmulation#NATIVE}: A few dialects have native + * support for MULTISET.
  • + *
  • {@link NestedCollectionEmulation#DEFAULT}: By default, jOOQ chooses + * the optimal encoding among the above depending on your dialect, + * transparently.
  • + *
+ *

+ * The emulation to be chosen is governed by + * {@link Settings#getEmulateMultiset()}. + *

+ *

+ * A set of known limitations can be found here: https://github.com/jOOQ/jOOQ/issues/12021. + * An important known limitation is that predicates based on + * MULTISETs expose undefined behaviour: Either they don't work + * (uncomparable types, such as XML), or they will compare JSON/XML document + * structures where ordinals matter. Please do not rely on the current + * comparison behaviour. + *

+ * Please report any issues you may encounter on the above issue, or in a + * new issue on github. + */ + @NotNull + @Support({ H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) + public static ArrayAggOrderByStep>> multisetAgg(SelectField field1, SelectField field2, SelectField field3, SelectField field4, SelectField field5, SelectField field6, SelectField field7, SelectField field8, SelectField field9, SelectField field10, SelectField field11, SelectField field12, SelectField field13, SelectField field14, SelectField field15, SelectField field16, SelectField field17, SelectField field18, SelectField field19, SelectField field20, SelectField field21, SelectField field22) { + return new MultisetAgg<>(false, row(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21, field22)); + } + + + diff --git a/jOOQ/src/main/java/org/jooq/impl/MultisetAgg.java b/jOOQ/src/main/java/org/jooq/impl/MultisetAgg.java new file mode 100644 index 0000000000..d652187442 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/MultisetAgg.java @@ -0,0 +1,128 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: http://www.jooq.org/licenses + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +// ... +import static org.jooq.impl.DSL.jsonArray; +import static org.jooq.impl.DSL.jsonArrayAgg; +import static org.jooq.impl.DSL.jsonObject; +import static org.jooq.impl.DSL.jsonbArray; +import static org.jooq.impl.DSL.jsonbArrayAgg; +import static org.jooq.impl.DSL.jsonbObject; +import static org.jooq.impl.DSL.select; +import static org.jooq.impl.DSL.selectFrom; +import static org.jooq.impl.DSL.xmlagg; +import static org.jooq.impl.DSL.xmlelement; +import static org.jooq.impl.Keywords.K_MULTISET; +import static org.jooq.impl.Names.N_ARRAY_AGG; +import static org.jooq.impl.Names.N_MULTISET_AGG; +import static org.jooq.impl.Names.N_RECORD; +import static org.jooq.impl.Names.N_RESULT; +import static org.jooq.impl.Tools.emulateMultiset; +import static org.jooq.impl.Tools.map; +import static org.jooq.impl.Tools.visitSubquery; + +import org.jooq.AggregateFunction; +import org.jooq.Context; +import org.jooq.Field; +import org.jooq.Record; +import org.jooq.Result; +import org.jooq.Row; +import org.jooq.SelectField; +import org.jooq.Table; + +/** + * @author Lukas Eder + */ +final class MultisetAgg extends DefaultAggregateFunction> { + + private final AbstractRow row; + + MultisetAgg(boolean distinct, SelectField row) { + super(distinct, N_MULTISET_AGG, new MultisetDataType<>((AbstractRow) row, null), (((AbstractRow) row).fields())); + + this.row = (AbstractRow) row; + } + + @Override + public final void accept(Context ctx) { + + + + + + + + + + + + + switch (emulateMultiset(ctx.configuration())) { + case JSON: { + ctx.visit(ofo((AbstractAggregateFunction) jsonArrayAgg(jsonObject(row.fields())))); + break; + } + + case JSONB: { + ctx.visit(ofo((AbstractAggregateFunction) jsonbArrayAgg(jsonObject(row.fields())))); + break; + } + + case XML: { + ctx.visit(xmlelement(N_RESULT, + ofo((AbstractAggregateFunction) + xmlagg(xmlelement(N_RECORD, + map(row.fields(), f -> xmlelement(f.getUnqualifiedName(), f)) + )) + ) + )); + break; + } + + case NATIVE: + ctx.visit(N_MULTISET_AGG).sql('('); + acceptArguments1(ctx, new QueryPartListView<>(arguments.get(0))); + acceptOrderBy(ctx); + ctx.sql(')'); + acceptFilterClause(ctx); + acceptOverClause(ctx); + break; + } + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/MultisetDataType.java b/jOOQ/src/main/java/org/jooq/impl/MultisetDataType.java index a8fec74240..e3400fb0a2 100644 --- a/jOOQ/src/main/java/org/jooq/impl/MultisetDataType.java +++ b/jOOQ/src/main/java/org/jooq/impl/MultisetDataType.java @@ -39,8 +39,6 @@ package org.jooq.impl; import static org.jooq.impl.Tools.CTX; import static org.jooq.impl.Tools.newRecord; -import static org.jooq.impl.Tools.recordType; -import static org.jooq.impl.Tools.row0; import java.util.List; @@ -51,8 +49,6 @@ import org.jooq.Nullability; import org.jooq.Record; import org.jooq.Result; import org.jooq.Row; -import org.jooq.Select; -import org.jooq.impl.AbstractRecord.TransferRecordState; /** * A wrapper for anonymous multiset data types. diff --git a/jOOQ/src/main/java/org/jooq/impl/Names.java b/jOOQ/src/main/java/org/jooq/impl/Names.java index cb8b8227ef..bf8b04792a 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Names.java +++ b/jOOQ/src/main/java/org/jooq/impl/Names.java @@ -248,6 +248,7 @@ final class Names { static final Name N_MODE = unquotedName("mode"); static final Name N_MUL = unquotedName("mul"); static final Name N_MULTISET = unquotedName("multiset"); + static final Name N_MULTISET_AGG = unquotedName("multiset_agg"); static final Name N_NANO100_BETWEEN = unquotedName("nano100_between"); static final Name N_NEWID = unquotedName("newid"); static final Name N_NEXTVAL = unquotedName("nextval"); diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index 22cde9e8d5..d244b94180 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -10422,6 +10422,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext { over = filter = parseOrderedSetFunctionIf(); if (filter == null && !basic) over = filter = parseArrayAggFunctionIf(); + if (filter == null && !basic) + over = filter = parseMultisetAggFunctionIf(); if (filter == null && !basic) over = filter = parseXMLAggFunctionIf(); if (filter == null && !basic) @@ -10847,6 +10849,24 @@ final class DefaultParseContext extends AbstractScope implements ParseContext { return null; } + private final AggregateFilterStep parseMultisetAggFunctionIf() { + if (parseKeywordIf("MULTISET_AGG")) { + parse('('); + + List> fields = parseList(',', ParseContext::parseField); + List> sort = null; + + if (parseKeywordIf("ORDER BY")) + sort = parseList(',', ParseContext::parseSortField); + + parse(')'); + ArrayAggOrderByStep s1 = multisetAgg(fields); + return sort == null ? s1 : s1.orderBy(sort); + } + + return null; + } + private final List> parseWithinGroupN() { return parseWithinGroupN(false); } diff --git a/jOOQ/src/main/resources/xsd/jooq-runtime-3.15.0.xsd b/jOOQ/src/main/resources/xsd/jooq-runtime-3.15.0.xsd index b7a82f0351..6bbe0d6fb6 100644 --- a/jOOQ/src/main/resources/xsd/jooq-runtime-3.15.0.xsd +++ b/jOOQ/src/main/resources/xsd/jooq-runtime-3.15.0.xsd @@ -552,16 +552,8 @@ jOOQ queries, for which no specific fetchSize value was specified.]]> - - LIST support should be emulated.]]> - - - MULTISET support should be emulated.]]> - - - - SET support should be emulated.]]> + MULTISET support should be emulated.]]>