mirror of https://github.com/apache/openjpa.git
OPENJPA-46: TRUE and FALSE should be case-insensitive in JPQL
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@515986 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d2c748d109
commit
69c34cd385
|
@ -248,7 +248,6 @@ TOKEN : /* literals */
|
|||
| ((["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: "'"
|
||||
(("''" | ~["'"])
|
||||
|
@ -277,6 +276,11 @@ TOKEN : /* literals */
|
|||
>
|
||||
}
|
||||
|
||||
TOKEN [ IGNORE_CASE ]: /* boolean literals can be case-insensitive */
|
||||
{
|
||||
< BOOLEAN_LITERAL: "TRUE" | "FALSE" >
|
||||
}
|
||||
|
||||
/* From the Java 1.0.2 specification */
|
||||
TOKEN : /* IDENTIFIERS */
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue