openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r808198 - in /openjpa/trunk: openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJDBCEscapeDate.java
Date Wed, 26 Aug 2009 22:01:26 GMT
Author: faywang
Date: Wed Aug 26 22:01:25 2009
New Revision: 808198

URL: http://svn.apache.org/viewvc?rev=808198&view=rev
Log:
OPENJPA-1266: JDBC escape syntax for date, time, timestamp support

Modified:
    openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJDBCEscapeDate.java

Modified: openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt?rev=808198&r1=808197&r2=808198&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt (original)
+++ openjpa/trunk/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt Wed
Aug 26 22:01:25 2009
@@ -293,23 +293,11 @@
 	  )
 	  "'"
 	>
-	| < DATE_LITERAL: "{d '" (["0"-"9"])(["0"-"9"])(["0"-"9"])(["0"-"9"]) ("-") 
-	                   (["0"-"1"])(["0"-"9"]) ("-") 
-	                   (["0"-"3"])(["0"-"9"]) "'}" 
+	| < DATE_LITERAL: "{d '" (["0"-"9", "-"])* "'}" 
 	>
-	| < TIME_LITERAL: "{t '" (["0"-"2"])(["0"-"9"]) (":") 
-	                   (["0"-"6"])(["0"-"9"]) (":") 
-	                   (["0"-"6"])(["0"-"9"]) "'}" 
+	| < TIME_LITERAL: "{t '" (["0"-"9", ":"])* "'}" 
 	>
-	| < TIMESTAMP_LITERAL: "{ts '" (["0"-"9"])(["0"-"9"])(["0"-"9"])(["0"-"9"]) ("-") 
-	                   (["0"-"1"])(["0"-"9"]) ("-") 
-	                   (["0"-"3"])(["0"-"9"]) (" ")
-	                   (["0"-"2"])(["0"-"9"]) (":") 
-	                   (["0"-"6"])(["0"-"9"]) (":") 
-	                   (["0"-"6"])(["0"-"9"]) 
-	                   ((".") (["0"-"9"]) (["0"-"9"])? (["0"-"9"])? (["0"-"9"])?
-	                   (["0"-"9"])? (["0"-"9"])? )?
-	                   "'}" 
+	| < TIMESTAMP_LITERAL: "{ts '" (["0"-"9", "-", ":", " ", "."])* "'}" 
 	>
 }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJDBCEscapeDate.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJDBCEscapeDate.java?rev=808198&r1=808197&r2=808198&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJDBCEscapeDate.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJDBCEscapeDate.java
Wed Aug 26 22:01:25 2009
@@ -55,14 +55,16 @@
         
         String[] jpql = {
             "select a from Employee a where a.hireDate >= {d '2009-08-25'}",
+            "select a from Employee a where a.hireDate >= {d '2009-8-5'}",
             "select a from Employee a where a.hireTime >= {t '00:00:00'}",
             "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00'}",
+            "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.'}",
             "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.1'}",
-            "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.11'}",
-            "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.111'}",
-            "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.1111'}",
-            "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.11111'}",
-            "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.111111'}",
+            "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.12'}",
+            "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.123'}",
+            "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.1234'}",
+            "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.12345'}",
+            "select a from Employee a where a.hireTimestamp >= {ts '2009-08-25 00:00:00.123456'}",
             "select {t '00:00:00'}, a.empId from Employee a",
         };
 
@@ -72,16 +74,8 @@
             Assert.assertEquals(1, results.size());
         }
 
-        String wrongTs = "select a from Employee a where a.hireTimestamp > {ts '2009-08-25
00:00:00.1111111'}";
-        try {
-            Query q = em.createQuery(wrongTs);
-            List results = q.getResultList();
-            Assert.fail();
-        } catch (Exception ex) {
-        }
-
         em.getTransaction().begin();
-        String update = "update Employee a set a.hireTimestamp = {ts '2009-08-25 00:00:00.111111'}
where a.empId = 1";
+        String update = "update Employee a set a.hireTimestamp = {ts '2009-08-25 00:00:00.123456'}
where a.empId = 1";
         Query q = em.createQuery(update);
         int updateCnt = q.executeUpdate();
         em.getTransaction().commit();



Mime
View raw message