Author: doogie
Date: Sun Nov 22 20:07:29 2009 New Revision: 883138 URL: http://svn.apache.org/viewvc?rev=883138&view=rev Log: Add flags to disable joins on DELETE and UPDATE. Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java?rev=883138&r1=883137&r2=883138&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java Sun Nov 22 20:07:29 2009 @@ -19,17 +19,24 @@ package org.ofbiz.entity.sql; import java.io.StringReader; +import java.util.List; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.sql.Parser; import org.ofbiz.sql.ParseException; +import org.ofbiz.sql.SQLPlan; +import org.ofbiz.sql.SQLStatement; public class SQLUtil { private static final EntityPlanner planner = new EntityPlanner(); + private static Parser updateParserFlags(Parser parser) { + return parser.deleteSupportsUsing(false).updateSupportsFrom(false); + } + public static EntitySelectPlan parseSelect(String sql) throws ParseException { - return planner.planSelect(new Parser(new StringReader(sql)).SelectStatement()); + return planner.planSelect(updateParserFlags(new Parser(new StringReader(sql))).SelectStatement()); } /* public static EntityCondition parseCondition(String condition) throws ParseException { 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=883138&r1=883137&r2=883138&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj Sun Nov 22 20:07:29 2009 @@ -47,6 +47,19 @@ import javolution.util.FastMap; public final class Parser { + private boolean deleteSupportsUsing = true; + private boolean updateSupportsFrom = true; + + public Parser deleteSupportsUsing(boolean value) { + deleteSupportsUsing = value; + return this; + } + + public Parser updateSupportsFrom(boolean value) { + updateSupportsFrom = value; + return this; + } + private Condition reduce(List<Condition> conditions, Joiner joiner) { if (conditions.size() == 1) { return conditions.get(0); @@ -306,7 +319,7 @@ <SET> setFields=SetField() { allSetFields.addAll(setFields); } ( <COMMA> setFields=SetField() { allSetFields.addAll(setFields); } )* - ( <FROM> joined=JoinedRest(false, tableName) )? + ( LOOKAHEAD(<FROM>, {updateSupportsFrom}) <FROM> joined=JoinedRest(false, tableName) )? ( <WHERE> whereCondition=ConditionExpression() )? { return new SQLUpdate(new Table(tableName, joined), allSetFields, whereCondition); } } @@ -320,7 +333,7 @@ } { <DELETE> <FROM> tableName=TableName() - ( <USING> joined=JoinedRest(false, tableName) )? + ( LOOKAHEAD(<USING>, {deleteSupportsUsing}) <USING> joined=JoinedRest(false, tableName) )? ( <WHERE> whereCondition=ConditionExpression() )? { return new SQLDelete(new Table(tableName, joined), whereCondition); } } |
Free forum by Nabble | Edit this page |