提交 bdb244ac authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Extract Parser.readFilterCondition()

上级 c5bef216
...@@ -2631,6 +2631,17 @@ public class Parser { ...@@ -2631,6 +2631,17 @@ public class Parser {
} }
} }
private Expression readFilterCondition() {
if (readIf("FILTER")) {
read("(");
read("WHERE");
Expression filterCondition = readExpression();
read(")");
return filterCondition;
}
return null;
}
private Expression readAggregate(AggregateType aggregateType, String aggregateName) { private Expression readAggregate(AggregateType aggregateType, String aggregateName) {
if (currentSelect == null) { if (currentSelect == null) {
throw getSyntaxError(); throw getSyntaxError();
...@@ -2695,12 +2706,8 @@ public class Parser { ...@@ -2695,12 +2706,8 @@ public class Parser {
distinct); distinct);
} }
read(")"); read(")");
if (r != null && readIf("FILTER")) { if (r != null) {
read("("); r.setFilterCondition(readFilterCondition());
read("WHERE");
Expression condition = readExpression();
read(")");
r.setFilterCondition(condition);
} }
return r; return r;
} }
...@@ -2750,15 +2757,7 @@ public class Parser { ...@@ -2750,15 +2757,7 @@ public class Parser {
do { do {
params.add(readExpression()); params.add(readExpression());
} while (readIfMore(true)); } while (readIfMore(true));
Expression filterCondition; Expression filterCondition = readFilterCondition();
if (readIf("FILTER")) {
read("(");
read("WHERE");
filterCondition = readExpression();
read(")");
} else {
filterCondition = null;
}
Expression[] list = params.toArray(new Expression[0]); Expression[] list = params.toArray(new Expression[0]);
JavaAggregate agg = new JavaAggregate(aggregate, list, currentSelect, distinct, filterCondition); JavaAggregate agg = new JavaAggregate(aggregate, list, currentSelect, distinct, filterCondition);
currentSelect.setGroupQuery(); currentSelect.setGroupQuery();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论