From 39e1723d3745cacc2718291a710dad670f49bb3b Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 27 Jan 2012 14:39:09 +0000 Subject: [PATCH] [#1073] Add integration tests for NOT IN queries holding NULL arguments --- .../src/org/jooq/test/jOOQAbstractTest.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java b/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java index 763f446e4f..895004cf60 100644 --- a/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java +++ b/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java @@ -3078,15 +3078,28 @@ public abstract class jOOQAbstractTest< asList(1), create().select(TBook_ID()) .from(TBook()) - .where(TBook_ID().in(1, null)) - .fetch(TBook_ID())); - assertEquals( - asList(), - create().select(TBook_ID()) - .from(TBook()) - .where(TBook_ID().notIn(1, null)) + .where(TBook_ID().in(val(1), castNull(Integer.class))) .fetch(TBook_ID())); + // [#1073] Some dialects incorrectly handle NULL in NOT IN predicates + if (asList(ASE, HSQLDB, MYSQL).contains(getDialect())) { + assertEquals( + asList(2, 3, 4), + create().select(TBook_ID()) + .from(TBook()) + .where(TBook_ID().notIn(val(1), castNull(Integer.class))) + .orderBy(TBook_ID()) + .fetch(TBook_ID())); + } + else { + assertEquals( + asList(), + create().select(TBook_ID()) + .from(TBook()) + .where(TBook_ID().notIn(val(1), castNull(Integer.class))) + .fetch(TBook_ID())); + } + assertEquals(Arrays.asList(1, 2), create().select() .from(TBook()) .where(TBook_ID().in(1, 2))