From 1807e1cc43163d6497780cfbb53d03ede6ce98f8 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sun, 25 Jun 2023 20:06:07 +0200 Subject: [PATCH] extra test for 'is distinct from' --- .../orm/test/query/hql/DistinctFromTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/DistinctFromTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/DistinctFromTest.java index 0356856a99..1b154e5c0d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/DistinctFromTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/DistinctFromTest.java @@ -19,6 +19,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * @author Christian Beikov */ @@ -115,4 +117,19 @@ public class DistinctFromTest { ); } + @Test void testNulls(SessionFactoryScope scope) { + scope.inSession(session -> { + assertEquals(1, session.createSelectionQuery("select 1 where 1 is distinct from 0").getResultList().size()); + assertEquals(0, session.createSelectionQuery("select 1 where 1 is distinct from 1").getResultList().size()); + assertEquals(1, session.createSelectionQuery("select 1 where null is distinct from 1").getResultList().size()); + assertEquals(1, session.createSelectionQuery("select 1 where null is distinct from 0").getResultList().size()); + assertEquals(0, session.createSelectionQuery("select 1 where null is distinct from null").getResultList().size()); + + assertEquals(0, session.createSelectionQuery("select 1 where 1 is not distinct from 0").getResultList().size()); + assertEquals(1, session.createSelectionQuery("select 1 where 1 is not distinct from 1").getResultList().size()); + assertEquals(0, session.createSelectionQuery("select 1 where null is not distinct from 1").getResultList().size()); + assertEquals(0, session.createSelectionQuery("select 1 where null is not distinct from 0").getResultList().size()); + assertEquals(1, session.createSelectionQuery("select 1 where null is not distinct from null").getResultList().size()); + }); + } } \ No newline at end of file