Author: doogie
Date: Mon Aug 2 17:43:19 2010
New Revision: 981630
URL:
http://svn.apache.org/viewvc?rev=981630&view=revLog:
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
;