cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [cayenne] branch master updated: Fix translation of NULL values - fix tests on Derby
Date Tue, 14 May 2019 12:16:16 GMT
This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new 860eec4  Fix translation of NULL values  - fix tests on Derby
860eec4 is described below

commit 860eec49e9a6fe08661d9e51cb8f6e0dbab61481
Author: Nikita Timofeev <stariy95@gmail.com>
AuthorDate: Tue May 14 15:16:04 2019 +0300

    Fix translation of NULL values
     - fix tests on Derby
---
 .../java/org/apache/cayenne/exp/ExpressionIT.java  | 30 +++++++++++++++++++---
 .../apache/cayenne/unit/DerbyUnitDbAdapter.java    |  5 ++++
 .../org/apache/cayenne/unit/UnitDbAdapter.java     |  4 +++
 3 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/cayenne-server/src/test/java/org/apache/cayenne/exp/ExpressionIT.java b/cayenne-server/src/test/java/org/apache/cayenne/exp/ExpressionIT.java
index 1149b20..08b7aca 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/exp/ExpressionIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/exp/ExpressionIT.java
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.exp;
 
+import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.access.DataContext;
 import org.apache.cayenne.configuration.server.ServerRuntime;
@@ -27,6 +28,7 @@ import org.apache.cayenne.query.ObjectSelect;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.testdo.testmap.Painting;
+import org.apache.cayenne.unit.UnitDbAdapter;
 import org.apache.cayenne.unit.di.server.CayenneProjects;
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
@@ -51,6 +53,9 @@ public class ExpressionIT extends ServerCase {
 	@Inject
 	private ServerRuntime runtime;
 
+	@Inject
+    private UnitDbAdapter adapter;
+
     @Test
 	public void testMatch() {
 
@@ -132,8 +137,18 @@ public class ExpressionIT extends ServerCase {
 		a1.setArtistName("Picasso");
 		context.commitChanges();
 
-		List<Artist> artists = ObjectSelect.query(Artist.class, Artist.ARTIST_NAME.lt((String)null)).select(context);
-		assertTrue("Less than 'NULL' never matches anything", artists.isEmpty());
+        List<Artist> artists;
+		try {
+            artists = ObjectSelect.query(Artist.class, Artist.ARTIST_NAME.lt((String) null)).select(context);
+        } catch (CayenneRuntimeException ex) {
+		    if(adapter.supportsNullComparision()) {
+		        throw ex;
+            } else {
+		        return;
+            }
+        }
+
+        assertTrue("Less than 'NULL' never matches anything", artists.isEmpty());
 	}
 
 	@Test
@@ -142,7 +157,16 @@ public class ExpressionIT extends ServerCase {
 		a1.setArtistName("Picasso");
 		context.commitChanges();
 
-		List<Artist> artists = ObjectSelect.query(Artist.class, Artist.ARTIST_NAME.in("Picasso",
(String)null)).select(context);
+        List<Artist> artists;
+        try {
+            artists = ObjectSelect.query(Artist.class, Artist.ARTIST_NAME.in("Picasso", (String)
null)).select(context);
+        } catch (CayenneRuntimeException ex) {
+            if(adapter.supportsNullComparision()) {
+                throw ex;
+            } else {
+                return;
+            }
+        }
 		assertEquals(1, artists.size());
 	}
 
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/DerbyUnitDbAdapter.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/DerbyUnitDbAdapter.java
index 7c29e13..04db855 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/DerbyUnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/DerbyUnitDbAdapter.java
@@ -72,4 +72,9 @@ public class DerbyUnitDbAdapter extends UnitDbAdapter {
     public boolean supportsLongIn() {
         return false;
     }
+
+    @Override
+    public boolean supportsNullComparision() {
+        return false;
+    }
 }
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
index c57edd8..ae04f89 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
@@ -411,4 +411,8 @@ public class UnitDbAdapter {
     public boolean supportsLongIn() {
         return true;
     }
+
+    public boolean supportsNullComparision() {
+        return true;
+    }
 }


Mime
View raw message