DATACOUCH-251 - Wrap base where criteria with parenthesis for OR expressions.

Base criteria for the query should be wrapped before adding the entity filter criteria so the priority of filtering is clear.
This commit is contained in:
Subhashni Balakrishnan
2016-11-23 07:51:23 -08:00
committed by Oliver Gierke
parent ce8dd97d66
commit b52dee3a3c
4 changed files with 48 additions and 3 deletions

View File

@@ -20,6 +20,7 @@ import static com.couchbase.client.java.query.Select.select;
import static com.couchbase.client.java.query.dsl.Expression.i;
import static com.couchbase.client.java.query.dsl.Expression.path;
import static com.couchbase.client.java.query.dsl.Expression.s;
import static com.couchbase.client.java.query.dsl.Expression.x;
import static com.couchbase.client.java.query.dsl.functions.AggregateFunctions.count;
import static com.couchbase.client.java.query.dsl.functions.MetaFunctions.meta;
import static com.couchbase.client.java.query.dsl.functions.StringFunctions.lower;
@@ -149,7 +150,7 @@ public class N1qlUtils {
if (baseWhereCriteria == null) {
baseWhereCriteria = typeSelector;
} else {
baseWhereCriteria = baseWhereCriteria.and(typeSelector);
baseWhereCriteria = x("(" + baseWhereCriteria.toString() + ")").and(typeSelector);
}
return baseWhereCriteria;
}