+{
- Cardinality(Field extends Object[]> arg) {
- super(N_CARDINALITY, INTEGER);
+ private final Field extends Object[]> array;
- this.arg = arg;
+ Cardinality(
+ Field extends Object[]> array
+ ) {
+ super(
+ N_CARDINALITY,
+ allNotNull(INTEGER, array)
+ );
+
+ this.array = nullSafeNotNull(array, OTHER.getArrayDataType());
}
+ // -------------------------------------------------------------------------
+ // XXX: QueryPart API
+ // -------------------------------------------------------------------------
+
@Override
public final void accept(Context> ctx) {
+ switch (ctx.family()) {
- ctx.visit(N_CARDINALITY).sql('(').visit(arg).sql(')');
+
+ default:
+ ctx.visit(function(N_CARDINALITY, getDataType(), array));
+ break;
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+ // -------------------------------------------------------------------------
+ // The Object API
+ // -------------------------------------------------------------------------
+
+ @Override
+ public boolean equals(Object that) {
+ if (that instanceof Cardinality) {
+ return
+ StringUtils.equals(array, ((Cardinality) that).array)
+ ;
+ }
+ else
+ return super.equals(that);
}
}
diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java
index 262c4c3d83..37a072de69 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DSL.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java
@@ -18971,6 +18971,45 @@ public class DSL {
return new DateAdd(date, interval);
}
+ // -------------------------------------------------------------------------
+ // Array functions
+ // -------------------------------------------------------------------------
+
+ /**
+ * The CARDINALITY function.
+ *
+ * Calculate the cardinality of an array field.
+ */
+ @NotNull
+ @Support({ H2, HSQLDB, POSTGRES, YUGABYTE })
+ public static Field cardinality(Field extends Object[]> array) {
+ return new Cardinality(array);
+ }
+
+ /**
+ * The ARRAY_GET function.
+ *
+ * Get an array element at a given index (1 based).
+ *
+ * @param index is wrapped as {@link #val(Object)}.
+ */
+ @NotNull
+ @Support({ H2, HSQLDB, POSTGRES, YUGABYTE })
+ public static Field arrayGet(Field array, int index) {
+ return new ArrayGet(array, Tools.field(index));
+ }
+
+ /**
+ * The ARRAY_GET function.
+ *
+ * Get an array element at a given index (1 based).
+ */
+ @NotNull
+ @Support({ H2, HSQLDB, POSTGRES, YUGABYTE })
+ public static Field arrayGet(Field array, Field index) {
+ return new ArrayGet(array, index);
+ }
+
// -------------------------------------------------------------------------
// System functions
// -------------------------------------------------------------------------
@@ -23511,33 +23550,6 @@ public class DSL {
return new ArraySelect<>(select);
}
- /**
- * Calculate the cardinality of an array field.
- */
- @NotNull
- @Support({ H2, HSQLDB, POSTGRES, YUGABYTE })
- public static Field cardinality(Field extends Object[]> field) {
- return new Cardinality(field);
- }
-
- /**
- * Get an array element at a given index (1 based)
- */
- @NotNull
- @Support({ H2, HSQLDB, POSTGRES, YUGABYTE })
- public static Field arrayGet(Field field, int index) {
- return arrayGet(field, Tools.field(index));
- }
-
- /**
- * Get an array element at a given index (1 based)
- */
- @NotNull
- @Support({ H2, HSQLDB, POSTGRES, YUGABYTE })
- public static Field arrayGet(Field field, Field index) {
- return new ArrayGet<>(Tools.nullSafe(field), Tools.nullSafe(index));
- }
-
/**
* Get the MULTISET operator to nest subqueries.
*
diff --git a/pom.xml b/pom.xml
index 48508ef810..75a66f645a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,7 @@
2.5.1
- 42.2.22
+ 42.2.23
9.2.1.jre11
21.3.0.0
2.0.0.6