diff --git a/jOOQ-test/src/org/jooq/test/jOOQPostgresTest.java b/jOOQ-test/src/org/jooq/test/jOOQPostgresTest.java index 743526d954..8b7e2ed3f5 100644 --- a/jOOQ-test/src/org/jooq/test/jOOQPostgresTest.java +++ b/jOOQ-test/src/org/jooq/test/jOOQPostgresTest.java @@ -709,4 +709,41 @@ public class jOOQPostgresTest extends jOOQAbstractTest< assertEquals(U_959.class_, result.get(1)); assertEquals(U_959.public_, result.get(2)); } + + @Test + public void testPostgresArrayOperations() throws Exception { + + // [#1107] The contains operator @> is implemented in Field.contains() + // ------------------------------------------------------------------- + assertEquals(0, + create().selectCount() + .from(T_ARRAYS) + .where(T_ARRAYS.NUMBER_ARRAY.contains((Integer[])null)) + .fetchOne(0)); + + assertEquals(3, + create().selectCount() + .from(T_ARRAYS) + .where(T_ARRAYS.NUMBER_ARRAY.contains(new Integer[0])) + .fetchOne(0)); + + assertEquals(2, + create().selectCount() + .from(T_ARRAYS) + .where(T_ARRAYS.NUMBER_ARRAY.contains(new Integer[] { 1 })) + .fetchOne(0)); + + assertEquals(1, + create().selectCount() + .from(T_ARRAYS) + .where(T_ARRAYS.NUMBER_ARRAY.contains(new Integer[] { 1, 2 })) + .fetchOne(0)); + + assertEquals(0, + create().selectCount() + .from(T_ARRAYS) + .where(T_ARRAYS.NUMBER_ARRAY.contains(new Integer[] { 1, 2, 3 })) + .fetchOne(0)); + + } } diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/Routines.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/Routines.java index 4db641f367..2691949160 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/Routines.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/Routines.java @@ -11,7 +11,7 @@ package org.jooq.test.postgres.generatedclasses; public final class Routines { /** - * Invoke F_ARRAYS + * Call public.f_arrays * * @param inArray * @throws org.jooq.exception.DataAccessException if something went wrong executing the query @@ -25,7 +25,7 @@ public final class Routines { } /** - * Get F_ARRAYS as a field + * Get public.f_arrays as a field * * @param inArray */ @@ -37,7 +37,7 @@ public final class Routines { } /** - * Get F_ARRAYS as a field + * Get public.f_arrays as a field * * @param inArray */ @@ -49,7 +49,7 @@ public final class Routines { } /** - * Invoke F_ARRAYS + * Call public.f_arrays * * @param inArray * @throws org.jooq.exception.DataAccessException if something went wrong executing the query @@ -63,7 +63,7 @@ public final class Routines { } /** - * Get F_ARRAYS as a field + * Get public.f_arrays as a field * * @param inArray */ @@ -75,7 +75,7 @@ public final class Routines { } /** - * Get F_ARRAYS as a field + * Get public.f_arrays as a field * * @param inArray */ @@ -87,7 +87,7 @@ public final class Routines { } /** - * Invoke F_ARRAYS + * Call public.f_arrays * * @param inArray * @throws org.jooq.exception.DataAccessException if something went wrong executing the query @@ -101,7 +101,7 @@ public final class Routines { } /** - * Get F_ARRAYS as a field + * Get public.f_arrays as a field * * @param inArray */ @@ -113,7 +113,7 @@ public final class Routines { } /** - * Get F_ARRAYS as a field + * Get public.f_arrays as a field * * @param inArray */ @@ -125,7 +125,7 @@ public final class Routines { } /** - * Invoke F_AUTHOR_EXISTS + * Call public.f_author_exists * * @param authorName * @throws org.jooq.exception.DataAccessException if something went wrong executing the query @@ -139,7 +139,7 @@ public final class Routines { } /** - * Get F_AUTHOR_EXISTS as a field + * Get public.f_author_exists as a field * * @param authorName */ @@ -151,7 +151,7 @@ public final class Routines { } /** - * Get F_AUTHOR_EXISTS as a field + * Get public.f_author_exists as a field * * @param authorName */ @@ -163,7 +163,7 @@ public final class Routines { } /** - * Invoke F_GET_ONE_CURSOR + * Call public.f_get_one_cursor * * @param bookIds * @throws org.jooq.exception.DataAccessException if something went wrong executing the query @@ -177,7 +177,7 @@ public final class Routines { } /** - * Get F_GET_ONE_CURSOR as a field + * Get public.f_get_one_cursor as a field * * @param bookIds */ @@ -189,7 +189,7 @@ public final class Routines { } /** - * Get F_GET_ONE_CURSOR as a field + * Get public.f_get_one_cursor as a field * * @param bookIds */ @@ -201,7 +201,7 @@ public final class Routines { } /** - * Invoke F_NUMBER + * Call public.f_number * * @param n * @throws org.jooq.exception.DataAccessException if something went wrong executing the query @@ -215,7 +215,7 @@ public final class Routines { } /** - * Get F_NUMBER as a field + * Get public.f_number as a field * * @param n */ @@ -227,7 +227,7 @@ public final class Routines { } /** - * Get F_NUMBER as a field + * Get public.f_number as a field * * @param n */ @@ -239,7 +239,7 @@ public final class Routines { } /** - * Invoke F_ONE + * Call public.f_one * * @throws org.jooq.exception.DataAccessException if something went wrong executing the query */ @@ -251,7 +251,7 @@ public final class Routines { } /** - * Get F_ONE as a field + * Get public.f_one as a field * */ public static org.jooq.Field fOne() { @@ -261,7 +261,7 @@ public final class Routines { } /** - * Invoke F317 + * Call public.f317 * * @param p1 * @param p2 @@ -281,7 +281,7 @@ public final class Routines { } /** - * Get F317 as a field + * Get public.f317 as a field * * @param p1 * @param p2 @@ -299,7 +299,7 @@ public final class Routines { } /** - * Get F317 as a field + * Get public.f317 as a field * * @param p1 * @param p2 @@ -317,7 +317,7 @@ public final class Routines { } /** - * Invoke P_ARRAYS + * Call public.p_arrays * * @param inArray IN parameter * @param outArray OUT parameter @@ -332,7 +332,7 @@ public final class Routines { } /** - * Invoke P_ARRAYS + * Call public.p_arrays * * @param inArray IN parameter * @param outArray OUT parameter @@ -347,7 +347,7 @@ public final class Routines { } /** - * Invoke P_ARRAYS + * Call public.p_arrays * * @param inArray IN parameter * @param outArray OUT parameter @@ -362,7 +362,7 @@ public final class Routines { } /** - * Invoke P_AUTHOR_EXISTS + * Call public.p_author_exists * * @param authorName IN parameter * @param result OUT parameter @@ -377,7 +377,7 @@ public final class Routines { } /** - * Invoke P_CREATE_AUTHOR + * Call public.p_create_author * * @throws org.jooq.exception.DataAccessException if something went wrong executing the query */ @@ -388,7 +388,7 @@ public final class Routines { } /** - * Invoke P_CREATE_AUTHOR_BY_NAME + * Call public.p_create_author_by_name * * @param firstName IN parameter * @param lastName IN parameter @@ -403,7 +403,7 @@ public final class Routines { } /** - * Invoke P_ENHANCE_ADDRESS1 + * Call public.p_enhance_address1 * * @param address IN parameter * @param no OUT parameter @@ -418,7 +418,7 @@ public final class Routines { } /** - * Invoke P_ENHANCE_ADDRESS2 + * Call public.p_enhance_address2 * * @param address OUT parameter * @throws org.jooq.exception.DataAccessException if something went wrong executing the query @@ -431,7 +431,7 @@ public final class Routines { } /** - * Invoke P_ENHANCE_ADDRESS3 + * Call public.p_enhance_address3 * * @param address IN OUT parameter * @throws org.jooq.exception.DataAccessException if something went wrong executing the query @@ -445,7 +445,7 @@ public final class Routines { } /** - * Invoke P_GET_ONE_CURSOR + * Call public.p_get_one_cursor * * @param total OUT parameter * @param books OUT parameter @@ -461,7 +461,7 @@ public final class Routines { } /** - * Invoke P_GET_TWO_CURSORS + * Call public.p_get_two_cursors * * @param books OUT parameter * @param authors OUT parameter @@ -475,7 +475,7 @@ public final class Routines { } /** - * Invoke P_TRIGGERS + * Call public.p_triggers * * @throws org.jooq.exception.DataAccessException if something went wrong executing the query */ @@ -487,7 +487,7 @@ public final class Routines { } /** - * Get P_TRIGGERS as a field + * Get public.p_triggers as a field * */ public static org.jooq.Field pTriggers() { @@ -497,7 +497,7 @@ public final class Routines { } /** - * Invoke P_UNUSED + * Call public.p_unused * * @param in1 IN parameter * @param out1 OUT parameter @@ -514,7 +514,7 @@ public final class Routines { } /** - * Invoke P391 + * Call public.p391 * * @param i1 IN parameter * @param io1 IN OUT parameter diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TArrays.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TArrays.java index cf1b1c08df..8d2869d471 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TArrays.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TArrays.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class TArrays extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = 1751903858; + private static final long serialVersionUID = -669017663; /** - * The singleton instance of t_arrays + * The singleton instance of public.t_arrays */ public static final org.jooq.test.postgres.generatedclasses.tables.TArrays T_ARRAYS = new org.jooq.test.postgres.generatedclasses.tables.TArrays(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TAuthor.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TAuthor.java index 84d35a89d3..4b8e50a2de 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TAuthor.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TAuthor.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class TAuthor extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = 860783999; + private static final long serialVersionUID = -7636340; /** - * The singleton instance of t_author + * The singleton instance of public.t_author */ public static final org.jooq.test.postgres.generatedclasses.tables.TAuthor T_AUTHOR = new org.jooq.test.postgres.generatedclasses.tables.TAuthor(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBook.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBook.java index 0b6be46564..21cc4d497f 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBook.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBook.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class TBook extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = 884711017; + private static final long serialVersionUID = -1441052876; /** - * The singleton instance of t_book + * The singleton instance of public.t_book */ public static final org.jooq.test.postgres.generatedclasses.tables.TBook T_BOOK = new org.jooq.test.postgres.generatedclasses.tables.TBook(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBookStore.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBookStore.java index 00fcc148d4..fb96acfa2d 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBookStore.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBookStore.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class TBookStore extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = 1823166931; + private static final long serialVersionUID = 882832138; /** - * The singleton instance of t_book_store + * The singleton instance of public.t_book_store */ public static final org.jooq.test.postgres.generatedclasses.tables.TBookStore T_BOOK_STORE = new org.jooq.test.postgres.generatedclasses.tables.TBookStore(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBookToBookStore.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBookToBookStore.java index 0391385795..293be36156 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBookToBookStore.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBookToBookStore.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class TBookToBookStore extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = -647448628; + private static final long serialVersionUID = 974465859; /** - * The singleton instance of t_book_to_book_store + * The singleton instance of public.t_book_to_book_store */ public static final org.jooq.test.postgres.generatedclasses.tables.TBookToBookStore T_BOOK_TO_BOOK_STORE = new org.jooq.test.postgres.generatedclasses.tables.TBookToBookStore(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBooleans.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBooleans.java index 841b5298f2..667f2c6689 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBooleans.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TBooleans.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class TBooleans extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = 1774781543; + private static final long serialVersionUID = 1994252730; /** - * The singleton instance of t_booleans + * The singleton instance of public.t_booleans */ public static final org.jooq.test.postgres.generatedclasses.tables.TBooleans T_BOOLEANS = new org.jooq.test.postgres.generatedclasses.tables.TBooleans(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TDates.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TDates.java index 0d932d558b..1518ad6a4b 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TDates.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TDates.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class TDates extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = -1409756932; + private static final long serialVersionUID = 335309541; /** - * The singleton instance of t_dates + * The singleton instance of public.t_dates */ public static final org.jooq.test.postgres.generatedclasses.tables.TDates T_DATES = new org.jooq.test.postgres.generatedclasses.tables.TDates(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TIdentity.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TIdentity.java index 8af1ffc21e..47f82d04e9 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TIdentity.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TIdentity.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class TIdentity extends org.jooq.impl.TableImpl { - private static final long serialVersionUID = -1727765735; + private static final long serialVersionUID = -471519130; /** - * The singleton instance of t_identity + * The singleton instance of public.t_identity */ public static final org.jooq.test.postgres.generatedclasses.tables.TIdentity T_IDENTITY = new org.jooq.test.postgres.generatedclasses.tables.TIdentity(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TIdentityPk.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TIdentityPk.java index 5956356017..c49859a068 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TIdentityPk.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TIdentityPk.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class TIdentityPk extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = 217982289; + private static final long serialVersionUID = 642491046; /** - * The singleton instance of t_identity_pk + * The singleton instance of public.t_identity_pk */ public static final org.jooq.test.postgres.generatedclasses.tables.TIdentityPk T_IDENTITY_PK = new org.jooq.test.postgres.generatedclasses.tables.TIdentityPk(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TTriggers.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TTriggers.java index c460823bf0..8228afe9a8 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TTriggers.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/TTriggers.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class TTriggers extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = 1722759821; + private static final long serialVersionUID = -1990301350; /** - * The singleton instance of t_triggers + * The singleton instance of public.t_triggers */ public static final org.jooq.test.postgres.generatedclasses.tables.TTriggers T_TRIGGERS = new org.jooq.test.postgres.generatedclasses.tables.TTriggers(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_639NumbersTable.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_639NumbersTable.java index 6cc2a598cc..3244e33ffe 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_639NumbersTable.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_639NumbersTable.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class T_639NumbersTable extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = -395812328; + private static final long serialVersionUID = 1784568845; /** - * The singleton instance of t_639_numbers_table + * The singleton instance of public.t_639_numbers_table */ public static final org.jooq.test.postgres.generatedclasses.tables.T_639NumbersTable T_639_NUMBERS_TABLE = new org.jooq.test.postgres.generatedclasses.tables.T_639NumbersTable(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_658Ref.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_658Ref.java index f6349ff024..3cbf9ef3a2 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_658Ref.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_658Ref.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class T_658Ref extends org.jooq.impl.TableImpl { - private static final long serialVersionUID = -900598214; + private static final long serialVersionUID = 1661790169; /** - * The singleton instance of t_658_ref + * The singleton instance of public.t_658_ref */ public static final org.jooq.test.postgres.generatedclasses.tables.T_658Ref T_658_REF = new org.jooq.test.postgres.generatedclasses.tables.T_658Ref(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_725LobTest.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_725LobTest.java index 086e50fc73..67d58a832e 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_725LobTest.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_725LobTest.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class T_725LobTest extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = -1348018481; + private static final long serialVersionUID = 1840202374; /** - * The singleton instance of t_725_lob_test + * The singleton instance of public.t_725_lob_test */ public static final org.jooq.test.postgres.generatedclasses.tables.T_725LobTest T_725_LOB_TEST = new org.jooq.test.postgres.generatedclasses.tables.T_725LobTest(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_785.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_785.java index cbcfdbd8b3..da7fff3c90 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_785.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_785.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class T_785 extends org.jooq.impl.TableImpl { - private static final long serialVersionUID = 49630399; + private static final long serialVersionUID = 421993292; /** - * The singleton instance of t_785 + * The singleton instance of public.t_785 */ public static final org.jooq.test.postgres.generatedclasses.tables.T_785 T_785 = new org.jooq.test.postgres.generatedclasses.tables.T_785(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_959.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_959.java index 13236c86e9..7285c5c952 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_959.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_959.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class T_959 extends org.jooq.impl.TableImpl { - private static final long serialVersionUID = -1003664711; + private static final long serialVersionUID = -744425146; /** - * The singleton instance of t_959 + * The singleton instance of public.t_959 */ public static final org.jooq.test.postgres.generatedclasses.tables.T_959 T_959 = new org.jooq.test.postgres.generatedclasses.tables.T_959(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_986_1.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_986_1.java index cf78583c6b..375fcb3d83 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_986_1.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_986_1.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class T_986_1 extends org.jooq.impl.TableImpl { - private static final long serialVersionUID = -469380001; + private static final long serialVersionUID = 1559256172; /** - * The singleton instance of t_986_1 + * The singleton instance of public.t_986_1 */ public static final org.jooq.test.postgres.generatedclasses.tables.T_986_1 T_986_1 = new org.jooq.test.postgres.generatedclasses.tables.T_986_1(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_986_2.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_986_2.java index 9547feb47c..63ddce77f7 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_986_2.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/T_986_2.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class T_986_2 extends org.jooq.impl.TableImpl { - private static final long serialVersionUID = -1770651142; + private static final long serialVersionUID = -630772153; /** - * The singleton instance of t_986_2 + * The singleton instance of public.t_986_2 */ public static final org.jooq.test.postgres.generatedclasses.tables.T_986_2 T_986_2 = new org.jooq.test.postgres.generatedclasses.tables.T_986_2(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VAuthor.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VAuthor.java index b4c15878ec..5c35724143 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VAuthor.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VAuthor.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class VAuthor extends org.jooq.impl.TableImpl { - private static final long serialVersionUID = 307768556; + private static final long serialVersionUID = 2083650111; /** - * The singleton instance of v_author + * The singleton instance of public.v_author */ public static final org.jooq.test.postgres.generatedclasses.tables.VAuthor V_AUTHOR = new org.jooq.test.postgres.generatedclasses.tables.VAuthor(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VBook.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VBook.java index 59331dcc17..55081dff3f 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VBook.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VBook.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class VBook extends org.jooq.impl.TableImpl { - private static final long serialVersionUID = -1755327145; + private static final long serialVersionUID = -53666140; /** - * The singleton instance of v_book + * The singleton instance of public.v_book */ public static final org.jooq.test.postgres.generatedclasses.tables.VBook V_BOOK = new org.jooq.test.postgres.generatedclasses.tables.VBook(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VLibrary.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VLibrary.java index 0493d5ec7d..e88073dabd 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VLibrary.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/VLibrary.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class VLibrary extends org.jooq.impl.TableImpl { - private static final long serialVersionUID = 285477391; + private static final long serialVersionUID = 1225516368; /** - * The singleton instance of v_library + * The singleton instance of public.v_library */ public static final org.jooq.test.postgres.generatedclasses.tables.VLibrary V_LIBRARY = new org.jooq.test.postgres.generatedclasses.tables.VLibrary(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_64_69.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_64_69.java index bc9c51185b..831c2cbb30 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_64_69.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_64_69.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class XTestCase_64_69 extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = -331440754; + private static final long serialVersionUID = 325449761; /** - * The singleton instance of x_test_case_64_69 + * The singleton instance of public.x_test_case_64_69 */ public static final org.jooq.test.postgres.generatedclasses.tables.XTestCase_64_69 X_TEST_CASE_64_69 = new org.jooq.test.postgres.generatedclasses.tables.XTestCase_64_69(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_71.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_71.java index f82fa485de..1dab12b34f 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_71.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_71.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class XTestCase_71 extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = 8582864; + private static final long serialVersionUID = -962881081; /** - * The singleton instance of x_test_case_71 + * The singleton instance of public.x_test_case_71 */ public static final org.jooq.test.postgres.generatedclasses.tables.XTestCase_71 X_TEST_CASE_71 = new org.jooq.test.postgres.generatedclasses.tables.XTestCase_71(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_85.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_85.java index 6615c5e86a..1d4f886622 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_85.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XTestCase_85.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class XTestCase_85 extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = 1044283848; + private static final long serialVersionUID = -1878057551; /** - * The singleton instance of x_test_case_85 + * The singleton instance of public.x_test_case_85 */ public static final org.jooq.test.postgres.generatedclasses.tables.XTestCase_85 X_TEST_CASE_85 = new org.jooq.test.postgres.generatedclasses.tables.XTestCase_85(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XUnused.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XUnused.java index 1005e7f1b0..b7a9dbf066 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XUnused.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/tables/XUnused.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.tables; */ public class XUnused extends org.jooq.impl.UpdatableTableImpl { - private static final long serialVersionUID = 1418269432; + private static final long serialVersionUID = 1016898761; /** - * The singleton instance of x_unused + * The singleton instance of public.x_unused */ public static final org.jooq.test.postgres.generatedclasses.tables.XUnused X_UNUSED = new org.jooq.test.postgres.generatedclasses.tables.XUnused(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/udt/UAddressType.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/udt/UAddressType.java index d0e344f59c..939794d951 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/udt/UAddressType.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/udt/UAddressType.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.udt; */ public class UAddressType extends org.jooq.impl.UDTImpl { - private static final long serialVersionUID = 1787194541; + private static final long serialVersionUID = -15622476; /** - * The singleton instance of u_address_type + * The singleton instance of public.u_address_type */ public static final org.jooq.test.postgres.generatedclasses.udt.UAddressType U_ADDRESS_TYPE = new org.jooq.test.postgres.generatedclasses.udt.UAddressType(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/udt/UStreetType.java b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/udt/UStreetType.java index 9e375ca0ee..8328624f62 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/udt/UStreetType.java +++ b/jOOQ-test/src/org/jooq/test/postgres/generatedclasses/udt/UStreetType.java @@ -8,10 +8,10 @@ package org.jooq.test.postgres.generatedclasses.udt; */ public class UStreetType extends org.jooq.impl.UDTImpl { - private static final long serialVersionUID = -318438597; + private static final long serialVersionUID = -578196600; /** - * The singleton instance of u_street_type + * The singleton instance of public.u_street_type */ public static final org.jooq.test.postgres.generatedclasses.udt.UStreetType U_STREET_TYPE = new org.jooq.test.postgres.generatedclasses.udt.UStreetType(); diff --git a/jOOQ-test/src/org/jooq/test/postgres/reset.sql b/jOOQ-test/src/org/jooq/test/postgres/reset.sql index 69bd5fe905..354891a942 100644 --- a/jOOQ-test/src/org/jooq/test/postgres/reset.sql +++ b/jOOQ-test/src/org/jooq/test/postgres/reset.sql @@ -60,11 +60,7 @@ INSERT INTO t_book_to_book_store VALUES ('Ex Libris', 1, 1)/ INSERT INTO t_book_to_book_store VALUES ('Ex Libris', 3, 2)/ INSERT INTO t_book_to_book_store VALUES ('Buchhandlung im Volkshaus', 3, 1)/ -INSERT INTO t_arrays VALUES (1, null, null, null, null, null, null) -/ -INSERT INTO t_arrays VALUES (2, '{}', '{}', '{}', '{}', '{}', '{}') -/ -INSERT INTO t_arrays VALUES (3, '{"a"}', '{1}', ARRAY[TO_DATE('1981-07-10', 'YYYY-MM-DD')], ARRAY[ROW('Downing Street', '10', null)]::u_street_type[], '{"England"}', ARRAY[ARRAY[1]]) -/ -INSERT INTO t_arrays VALUES (4, '{"a", "b"}', '{1, 2}', ARRAY[TO_DATE('1981-07-10', 'YYYY-MM-DD'), TO_DATE('2000-01-01', 'YYYY-MM-DD')], ARRAY[ROW('Downing Street', '10', '{}'), ROW('Bahnhofstrasse', '12', '{1, 2}')]::u_street_type[], '{"England", "Germany"}', ARRAY[ARRAY[1], ARRAY[2]]) -/ \ No newline at end of file +INSERT INTO t_arrays VALUES (1, null, null, null, null, null, null)/ +INSERT INTO t_arrays VALUES (2, '{}', '{}', '{}', '{}', '{}', '{}')/ +INSERT INTO t_arrays VALUES (3, '{"a"}', '{1}', ARRAY[TO_DATE('1981-07-10', 'YYYY-MM-DD')], ARRAY[ROW('Downing Street', '10', null)]::u_street_type[], '{"England"}', ARRAY[ARRAY[1]])/ +INSERT INTO t_arrays VALUES (4, '{"a", "b"}', '{1, 2}', ARRAY[TO_DATE('1981-07-10', 'YYYY-MM-DD'), TO_DATE('2000-01-01', 'YYYY-MM-DD')], ARRAY[ROW('Downing Street', '10', '{}'), ROW('Bahnhofstrasse', '12', '{1, 2}')]::u_street_type[], '{"England", "Germany"}', ARRAY[ARRAY[1], ARRAY[2]])/ \ No newline at end of file diff --git a/jOOQ/src/main/java/org/jooq/Field.java b/jOOQ/src/main/java/org/jooq/Field.java index 99bd8b9f6f..92e8089222 100644 --- a/jOOQ/src/main/java/org/jooq/Field.java +++ b/jOOQ/src/main/java/org/jooq/Field.java @@ -483,6 +483,15 @@ public interface Field extends NamedTypeProviderQueryPart, AliasProvider * Note: This also works with numbers, for instance * val(1133).contains(13) + *

+ * If you're using {@link SQLDialect#POSTGRES}, then you can use this method also to express the "ARRAY contains" operator. For example: + *

+     * // Use this expression
+     * val(new Integer[] { 1, 2, 3 }).contains(new Integer[] { 1, 2 })
+     *
+     * // ... to render this SQL
+     * ARRAY[1, 2, 3] @> ARRAY[1, 2]
+     * 
* * @see Factory#escape(String, char) * @see #like(Object, char) @@ -498,6 +507,15 @@ public interface Field extends NamedTypeProviderQueryPart, AliasProvider * Note: This also works with numbers, for instance * val(1133).contains(13) + *

+ * If you're using {@link SQLDialect#POSTGRES}, then you can use this method also to express the "ARRAY contains" operator. For example: + *

+     * // Use this expression
+     * val(new Integer[] { 1, 2, 3 }).contains(new Integer[] { 1, 2 })
+     *
+     * // ... to render this SQL
+     * ARRAY[1, 2, 3] @> ARRAY[1, 2]
+     * 
* * @see Factory#escape(Field, char) * @see #like(Field, char) diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractField.java b/jOOQ/src/main/java/org/jooq/impl/AbstractField.java index 3f140bee3f..dbbac86477 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractField.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractField.java @@ -39,7 +39,6 @@ import static org.jooq.impl.ExpressionOperator.ADD; import static org.jooq.impl.ExpressionOperator.DIVIDE; import static org.jooq.impl.ExpressionOperator.MULTIPLY; import static org.jooq.impl.ExpressionOperator.SUBTRACT; -import static org.jooq.impl.Factory.escape; import static org.jooq.impl.Factory.falseCondition; import static org.jooq.impl.Factory.literal; import static org.jooq.impl.Factory.nullSafe; @@ -79,7 +78,6 @@ abstract class AbstractField extends AbstractNamedTypeProviderQueryPart im * Generated UID */ private static final long serialVersionUID = 2884811923648354905L; - private static final char ESCAPE = '!'; AbstractField(String name, DataType type) { super(name, type); @@ -383,63 +381,36 @@ abstract class AbstractField extends AbstractNamedTypeProviderQueryPart im @Override public final Condition contains(T value) { - Field concat = Factory.concat(literal("'%'"), escapeForLike(value), literal("'%'")); - return like(concat, ESCAPE); + return new Contains(this, value); } @Override public final Condition contains(Field value) { - Field concat = Factory.concat(literal("'%'"), escapeForLike(value), literal("'%'")); - return like(concat, ESCAPE); + return new Contains(this, value); } @Override public final Condition startsWith(T value) { - Field concat = Factory.concat(escapeForLike(value), literal("'%'")); - return like(concat, ESCAPE); + Field concat = Factory.concat(Util.escapeForLike(value), literal("'%'")); + return like(concat, Util.ESCAPE); } @Override public final Condition startsWith(Field value) { - Field concat = Factory.concat(escapeForLike(value), literal("'%'")); - return like(concat, ESCAPE); + Field concat = Factory.concat(Util.escapeForLike(value), literal("'%'")); + return like(concat, Util.ESCAPE); } @Override public final Condition endsWith(T value) { - Field concat = Factory.concat(literal("'%'"), escapeForLike(value)); - return like(concat, ESCAPE); + Field concat = Factory.concat(literal("'%'"), Util.escapeForLike(value)); + return like(concat, Util.ESCAPE); } @Override public final Condition endsWith(Field value) { - Field concat = Factory.concat(literal("'%'"), escapeForLike(value)); - return like(concat, ESCAPE); - } - - /** - * Utility method to escape strings or "toString" other objects - */ - private final Field escapeForLike(Object value) { - if (value != null && value.getClass() == String.class) { - return val(escape("" + value, ESCAPE)); - } - else { - return val("" + value); - } - } - - /** - * Utility method to escape string fields, or cast other fields - */ - @SuppressWarnings("unchecked") - private final Field escapeForLike(Field field) { - if (nullSafe(field).getDataType().isString()) { - return escape((Field) field, ESCAPE); - } - else { - return field.cast(String.class); - } + Field concat = Factory.concat(literal("'%'"), Util.escapeForLike(value)); + return like(concat, Util.ESCAPE); } @Override diff --git a/jOOQ/src/main/java/org/jooq/impl/AttachableImpl.java b/jOOQ/src/main/java/org/jooq/impl/AttachableImpl.java index 38d4173b76..408b2063a5 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AttachableImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/AttachableImpl.java @@ -96,7 +96,9 @@ class AttachableImpl implements AttachableInternal { } for (Attachable attachable : getAttachables()) { - attachable.attach(c); + if (attachable != null) { + attachable.attach(c); + } } } diff --git a/jOOQ/src/main/java/org/jooq/impl/Contains.java b/jOOQ/src/main/java/org/jooq/impl/Contains.java new file mode 100644 index 0000000000..734bfe7210 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/Contains.java @@ -0,0 +1,144 @@ +/** + * Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com + * All rights reserved. + * + * This software is licensed to you under the Apache License, Version 2.0 + * (the "License"); You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * . Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * . Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * . Neither the name "jOOQ" nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package org.jooq.impl; + +import static org.jooq.impl.Factory.literal; +import static org.jooq.impl.Factory.val; + +import java.util.List; + +import org.jooq.Attachable; +import org.jooq.BindContext; +import org.jooq.Condition; +import org.jooq.Field; +import org.jooq.RenderContext; +import org.jooq.exception.DataAccessException; + +/** + * Abstraction for various "contains" operations + * + * @author Lukas Eder + */ +class Contains extends AbstractCondition { + + /** + * Generated UID + */ + private static final long serialVersionUID = 6146303086487338550L; + + private final Field lhs; + private final Field rhs; + private final T value; + + Contains(Field field, T value) { + this.lhs = field; + this.rhs = null; + this.value = value; + } + + Contains(Field field, Field rhs) { + this.lhs = field; + this.rhs = rhs; + this.value = null; + } + + @Override + public final void toSQL(RenderContext context) { + context.sql(condition()); + } + + @Override + public final void bind(BindContext context) throws DataAccessException { + context.bind(condition()); + } + + @Override + public final List getAttachables() { + return getAttachables(lhs, rhs); + } + + private final Condition condition() { + + // [#1107] Some dialects support "contains" operations for ARRAYs + if (lhs.getDataType().isArray()) { + return new PostgresArrayContains(); + } + + // "contains" operations on Strings + else { + Field concat; + + if (rhs == null) { + concat = Factory.concat(literal("'%'"), Util.escapeForLike(value), literal("'%'")); + } + else { + concat = Factory.concat(literal("'%'"), Util.escapeForLike(rhs), literal("'%'")); + } + + return lhs.like(concat, Util.ESCAPE); + } + } + + /** + * The Postgres array contains operator + */ + private class PostgresArrayContains extends AbstractCondition { + + /** + * Generated UID + */ + private static final long serialVersionUID = 8083622843635168388L; + + @Override + public final void toSQL(RenderContext context) { + context.sql(lhs).sql(" @> ").sql(rhs()); + } + + @Override + public final void bind(BindContext context) throws DataAccessException { + context.bind(lhs).bind(rhs()); + } + + private final Field rhs() { + return (rhs == null) ? val(value) : rhs; + } + + @Override + public List getAttachables() { + return getAttachables(lhs, rhs); + } + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/Util.java b/jOOQ/src/main/java/org/jooq/impl/Util.java index 6fc2f14444..a7e5b31d65 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Util.java +++ b/jOOQ/src/main/java/org/jooq/impl/Util.java @@ -37,7 +37,10 @@ package org.jooq.impl; import static java.lang.Boolean.FALSE; import static java.lang.Integer.toOctalString; +import static org.jooq.impl.Factory.escape; import static org.jooq.impl.Factory.getDataType; +import static org.jooq.impl.Factory.nullSafe; +import static org.jooq.impl.Factory.val; import static org.jooq.tools.StringUtils.leftPad; import java.lang.reflect.Constructor; @@ -81,17 +84,23 @@ import org.jooq.tools.StopWatchListener; import org.jooq.tools.StringUtils; /** - * General jooq utilities + * General jOOQ utilities * * @author Lukas Eder */ final class Util { + /** + * The default escape character for [a] LIKE [b] ESCAPE [...] + * clauses. + */ + static final char ESCAPE = '!'; + /** * Indicating whether JPA (javax.persistence) is on the * classpath. */ - private static Boolean isJPAAvailable; + private static Boolean isJPAAvailable; /** * Create a new Oracle-style VARRAY {@link ArrayRecord} @@ -926,4 +935,29 @@ final class Util { return sb.toString(); } + + /** + * Utility method to escape strings or "toString" other objects + */ + static final Field escapeForLike(Object value) { + if (value != null && value.getClass() == String.class) { + return val(escape("" + value, ESCAPE)); + } + else { + return val("" + value); + } + } + + /** + * Utility method to escape string fields, or cast other fields + */ + @SuppressWarnings("unchecked") + static final Field escapeForLike(Field field) { + if (nullSafe(field).getDataType().isString()) { + return escape((Field) field, ESCAPE); + } + else { + return field.cast(String.class); + } + } } \ No newline at end of file