openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r515986 - in /incubator/openjpa/trunk: openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestCaseInsensitiveKeywordsInJPQL.java
Date Thu, 08 Mar 2007 09:34:26 GMT
Author: pcl
Date: Thu Mar  8 01:34:25 2007
New Revision: 515986

URL: http://svn.apache.org/viewvc?view=rev&rev=515986
Log:
OPENJPA-46: TRUE and FALSE should be case-insensitive in JPQL

Added:
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestCaseInsensitiveKeywordsInJPQL.java
  (with props)
Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt?view=diff&rev=515986&r1=515985&r2=515986
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt
Thu Mar  8 01:34:25 2007
@@ -248,7 +248,6 @@
 		| ((["0"-"9"])+ ".") (<EXPONENT>)? (["f","F","d","D"])?
 		| ((["0"-"9"])+) (<EXPONENT>) (["f","F","d","D"])?
 		| ((["0"-"9"])+) (<EXPONENT>)? (["f","F","d","D"])?) >
-	| < BOOLEAN_LITERAL: "TRUE" | "FALSE" | "true" | "false" >
 	| < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
 	| < STRING_LITERAL: "'"
 	  (("''" | ~["'"])
@@ -275,6 +274,11 @@
 	  )
 	  "'"
 	>
+}
+
+TOKEN [ IGNORE_CASE ]: /* boolean literals can be case-insensitive */
+{
+	< BOOLEAN_LITERAL: "TRUE" | "FALSE" >
 }
 
 /* From the Java 1.0.2 specification */

Added: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestCaseInsensitiveKeywordsInJPQL.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestCaseInsensitiveKeywordsInJPQL.java?view=auto&rev=515986
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestCaseInsensitiveKeywordsInJPQL.java
(added)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestCaseInsensitiveKeywordsInJPQL.java
Thu Mar  8 01:34:25 2007
@@ -0,0 +1,41 @@
+package org.apache.openjpa.persistence.simple;
+
+import javax.persistence.Query;
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.test.PersistenceTestCase;
+
+public class TestCaseInsensitiveKeywordsInJPQL
+    extends PersistenceTestCase {
+
+    public Class[] getEntityTypes() {
+        return new Class[] { AllFieldTypes.class };
+    }
+
+    public void testCaseInsensitiveBooleans() {
+        EntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+
+        AllFieldTypes aft = new AllFieldTypes();
+        em.persist(aft);
+        aft.setBooleanField(true);
+
+        aft = new AllFieldTypes();
+        em.persist(aft);
+        aft.setBooleanField(false);
+
+        em.flush();
+
+        Query q = em.createQuery(
+            "select count(o) from AllFieldTypes o where o.booleanField = TrUe");
+        Number n = (Number) q.getSingleResult();
+        assertEquals(1, n.intValue());
+
+        q = em.createQuery("select count(o) from AllFieldTypes o "
+            + "where o.booleanField = falSe");
+        n = (Number) q.getSingleResult();
+        assertEquals(1, n.intValue());
+        
+        em.getTransaction().rollback();
+    }
+}
\ No newline at end of file

Propchange: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestCaseInsensitiveKeywordsInJPQL.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message