diff --git a/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java b/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java index edbfea6569..ec8573e546 100644 --- a/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java +++ b/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java @@ -38,6 +38,7 @@ import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.sql.BooleanCondition; import org.ofbiz.sql.Condition; import org.ofbiz.sql.ConditionList; +import org.ofbiz.sql.ConstantValue; import org.ofbiz.sql.FieldAll; import org.ofbiz.sql.FieldDef; import org.ofbiz.sql.FieldDefFieldValue; @@ -197,8 +198,8 @@ public class EntityPlanner extends Planner { +public final class MathValue extends StaticValue implements Iterable { private final String op; - private final List values; + private final List values; - public MathValue(String op, List values) { + public MathValue(String op, List values) { this.op = op; this.values = values; } @@ -40,7 +40,7 @@ public final class MathValue extends StaticValue implements Iterable iterator() { + public Iterator iterator() { return values.iterator(); } diff --git a/framework/sql/src/org/ofbiz/sql/Parser.jj b/framework/sql/src/org/ofbiz/sql/Parser.jj index ea9f450cf2..f98f173b28 100644 --- a/framework/sql/src/org/ofbiz/sql/Parser.jj +++ b/framework/sql/src/org/ofbiz/sql/Parser.jj @@ -557,16 +557,16 @@ private void FieldDef(Map fieldDefs, List fieldAlls, private StaticValue MathValue(): { - StaticValue v; - List values = FastList.newInstance(); + ConstantValue v; + List values = FastList.newInstance(); String operator = null, newOperator; } { - v=StaticValue() { values.add(v); } + v=ConstantValue() { values.add(v); } ( newOperator=MathOperator() - v=StaticValue() { + v=ConstantValue() { if (operator == null) { operator = newOperator; } else if (!newOperator.equals(operator)) { @@ -577,7 +577,7 @@ private StaticValue MathValue(): )* { - if (values.size() == 1) return values.get(0); + if (values.size() == 1 && values.get(0) instanceof StaticValue) return (StaticValue) values.get(0); return new MathValue(operator, values); } } @@ -597,16 +597,20 @@ private FunctionCall FunctionCallRest(String name): { return new FunctionCall(name, args); } } -private StaticValue StaticValue(): +private ConstantValue ConstantValue(): { String n; - StaticValue v; + ConstantValue v; + int i; + String s; } { n=NamePart() ( v=FunctionCallRest(n) { return v; } | v=FieldValue(n) { return v; } ) +| i=Integer() { return new NumberValue(i); } +| s=SQuoted() { return new StringValue(s); } | v=MathValue() { return v; } }