From 30d7b868ef01d4665422d5d241c9f0f149c6145f Mon Sep 17 00:00:00 2001 From: lukaseder Date: Mon, 26 Jan 2015 09:53:08 +0100 Subject: [PATCH] [#3985] Supported the array(select) function --- .../java/org/jooq/util/postgres/PostgresDSL.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java b/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java index cf07eed0a9..1466e1b72c 100644 --- a/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java +++ b/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java @@ -42,9 +42,12 @@ package org.jooq.util.postgres; import static org.jooq.SQLDialect.POSTGRES; +import org.jooq.DataType; import org.jooq.Field; import org.jooq.Record; +import org.jooq.Record1; import org.jooq.SQLDialect; +import org.jooq.Select; import org.jooq.Support; import org.jooq.Table; import org.jooq.impl.DSL; @@ -66,6 +69,18 @@ public class PostgresDSL extends DSL { // PostgreSQL-specific array functions // ------------------------------------------------------------------------- + /** + * The PostgreSQL array(select) function. + *

+ * Example:

+     * {1, 2, 3} = array(select 1 union select 2 union select 3)
+     * 
+ */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public static Field array(Select> select) { + return DSL.field("array({0})", (DataType) select.getSelect().get(0).getDataType().getArrayDataType(), select); + } + /** * The PostgreSQL array_append(anyarray, anyelement) function. *