svn commit: r981630 - in /ofbiz/trunk/framework/sql/src/org/ofbiz/sql: Parser.jj test/GoodParseAll.sql

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r981630 - in /ofbiz/trunk/framework/sql/src/org/ofbiz/sql: Parser.jj test/GoodParseAll.sql

doogie-3
Author: doogie
Date: Mon Aug  2 17:43:19 2010
New Revision: 981630

URL: http://svn.apache.org/viewvc?rev=981630&view=rev
Log:
BUG FIX: Fix parsing of -/+ style order by prefixes.

Modified:
    ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj
    ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/GoodParseAll.sql

Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj?rev=981630&r1=981629&r2=981630&view=diff
==============================================================================
--- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj (original)
+++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj Mon Aug  2 17:43:19 2010
@@ -699,17 +699,27 @@ private OrderByItem OrderByItem(): {
     OrderByItem.Order ordering = OrderByItem.Order.DEFAULT;
 } {
     (
-          <PLUS> { ordering = OrderByItem.Order.ASCENDING; }
-        | <MINUS> { ordering = OrderByItem.Order.DESCENDING; }
-    )?
-    (
-          ( <UPPER> | <LOWER> ) { functionName = getToken(0).image; } <OPEN_PAREN> fieldName=NamePart() <CLOSE_PAREN>
-        | fieldName=NamePart()
+          (
+            (
+                  <PLUS> { ordering = OrderByItem.Order.ASCENDING; }
+                | <MINUS> { ordering = OrderByItem.Order.DESCENDING; }
+            )
+            (
+                  ( <UPPER> | <LOWER> ) { functionName = getToken(0).image; }
+                  <OPEN_PAREN> fieldName=NamePart() <CLOSE_PAREN>
+                | fieldName=NamePart()
+            )
+          )
+        | (
+              ( <UPPER> | <LOWER> ) { functionName = getToken(0).image; }
+              <OPEN_PAREN> fieldName=NamePart() <CLOSE_PAREN>
+            | fieldName=NamePart()
+          )
+          (
+              <DESC> { ordering = OrderByItem.Order.DESCENDING; }
+            | <ASC> { ordering = OrderByItem.Order.ASCENDING; }
+          )?
     )
-    LOOKAHEAD({!orderingSet}) (
-          <DESC> { ordering = OrderByItem.Order.DESCENDING; }
-        | <ASC> { ordering = OrderByItem.Order.ASCENDING; }
-    )?
     { return new OrderByItem(ordering, functionName, fieldName); }
 }
 

Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/GoodParseAll.sql
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/GoodParseAll.sql?rev=981630&r1=981629&r2=981630&view=diff
==============================================================================
--- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/GoodParseAll.sql (original)
+++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/GoodParseAll.sql Mon Aug  2 17:43:19 2010
@@ -53,7 +53,7 @@ WHERE
 HAVING
     b.firstName LIKE '%foo%'
 ORDER BY
-    LOWER(lastName), firstName, birthDate DESC
+    LOWER(lastName), firstName, -birthDate
 OFFSET 5
 LIMIT 10
 ;