You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2025/09/23 02:50:03 UTC

(openjpa) 03/03: [WIP][OPENJPA-2940] Avoiding tests of criteria typecasts in unsupporting db (derbydb)

This is an automated email from the ASF dual-hosted git repository.

pcristof pushed a commit to branch OPENJPA-2940
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit d6ffe7c2dae26a78185f9226cf36ae32df5cd338
Author: Paulo Cristovão de Araújo Silva Filho <pc...@gmail.com>
AuthorDate: Mon Sep 22 23:29:15 2025 -0300

    [WIP][OPENJPA-2940] Avoiding tests of criteria typecasts in unsupporting db (derbydb)
---
 .../criteria/TestTypecastAsCriteria.java           | 31 +++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypecastAsCriteria.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypecastAsCriteria.java
index b342fecbf..fb5c0e855 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypecastAsCriteria.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypecastAsCriteria.java
@@ -36,11 +36,16 @@ import jakarta.persistence.criteria.Root;
 import jakarta.persistence.criteria.SetJoin;
 import jakarta.persistence.criteria.Subquery;
 
+import org.apache.openjpa.jdbc.sql.DerbyDictionary;
 import org.apache.openjpa.persistence.test.AllowFailure;
 
 public class TestTypecastAsCriteria extends CriteriaTest {
 
     public void testTypecastAsString() {
+    	if (getDictionary() instanceof DerbyDictionary) {
+    		// Derby does not support these CASTs
+    		return;
+    	}
     	String jpql = "SELECT c FROM Customer c JOIN c.orders o WHERE CAST(o.quantity AS String) = '0'";
     	CriteriaQuery<Customer> q = cb.createQuery(Customer.class);
     	Root<Customer> c = q.from(Customer.class);
@@ -52,6 +57,10 @@ public class TestTypecastAsCriteria extends CriteriaTest {
     }
 
     public void testTypecastAsInteger() {
+    	if (getDictionary() instanceof DerbyDictionary) {
+    		// Derby does not support these CASTs
+    		return;
+    	}
     	String jpql = "SELECT c FROM Customer c JOIN c.orders o WHERE CAST(CAST(o.quantity AS STRING) AS INTEGER) = 0";
     	CriteriaQuery<Customer> q = cb.createQuery(Customer.class);
     	Root<Customer> c = q.from(Customer.class);
@@ -63,7 +72,11 @@ public class TestTypecastAsCriteria extends CriteriaTest {
     }
 
     public void testTypecastAsLong() {
-    	String jpql = "SELECT c FROM Customer c JOIN c.orders o WHERE CAST(o.quantity AS LONG) = 0";
+    	if (getDictionary() instanceof DerbyDictionary) {
+    		// Derby does not support these CASTs
+    		return;
+    	}
+    	String jpql = "SELECT c FROM Customer c JOIN c.orders o WHERE CAST(CAST(o.quantity AS STRING) AS LONG) = 0";
     	CriteriaQuery<Customer> q = cb.createQuery(Customer.class);
     	Root<Customer> c = q.from(Customer.class);
     	SetJoin<Customer, Order> o = c.joinSet("orders");
@@ -74,7 +87,11 @@ public class TestTypecastAsCriteria extends CriteriaTest {
     }
 
     public void testTypecastAsFloat() {
-    	String jpql = "SELECT c FROM Customer c JOIN c.orders o WHERE CAST(o.quantity AS float) = 0";
+    	if (getDictionary() instanceof DerbyDictionary) {
+    		// Derby does not support these CASTs
+    		return;
+    	}
+    	String jpql = "SELECT c FROM Customer c JOIN c.orders o WHERE CAST(CAST(o.quantity AS STRING) AS float) = 0";
     	CriteriaQuery<Customer> q = cb.createQuery(Customer.class);
     	Root<Customer> c = q.from(Customer.class);
     	SetJoin<Customer, Order> o = c.joinSet("orders");
@@ -85,7 +102,11 @@ public class TestTypecastAsCriteria extends CriteriaTest {
     }
 
     public void testTypecastAsDouble() {
-    	String jpql = "SELECT c FROM Customer c JOIN c.orders o WHERE CAST(o.quantity AS double) = 0";
+    	if (getDictionary() instanceof DerbyDictionary) {
+    		// Derby does not support these CASTs
+    		return;
+    	}
+    	String jpql = "SELECT c FROM Customer c JOIN c.orders o WHERE CAST(cast(o.quantity as string) AS double) = 0";
     	CriteriaQuery<Customer> q = cb.createQuery(Customer.class);
     	Root<Customer> c = q.from(Customer.class);
     	SetJoin<Customer, Order> o = c.joinSet("orders");
@@ -96,6 +117,10 @@ public class TestTypecastAsCriteria extends CriteriaTest {
     }
     
     public void testTypecastAsInvalid() {
+    	if (getDictionary() instanceof DerbyDictionary) {
+    		// Derby does not support these CASTs
+    		return;
+    	}
     	CriteriaQuery<Customer> q = cb.createQuery(Customer.class);
     	Root<Customer> c = q.from(Customer.class);
     	SetJoin<Customer, Order> o = c.joinSet("orders");