I found that incorrect filter expression produces this line of code (for query with 'in' operator):
context.data = temp + context.data.replace(/\(/g, '').replace(/\)/g, '');
I replaced it with this code:
context.data = temp + context.data;
And now everything is working as expected. Maybe I introduced other issues with this fix, but at least it works as expected for my queries.
So the VisitSimpleBinaryExpression function looks like this now:
VisitSimpleBinaryExpression: function (expression, context) {
context.data += "(";
//TODO refactor!!!
if (expression.nodeType == "in") {
Guard.requireType("expression.right", expression.type, $data.Expressions.ConstantExpression);
var paramValue = expression.right.value;
if (!paramValue instanceof Array) { Guard.raise(new Exception("Right to the 'in' operator must be an array value")); }
var result = null;
var orResolution = { mapTo: "or", dataType: "boolean", name: "or" };
var eqResolution = { mapTo: "eq", dataType: "boolean", name: "equal" };
paramValue.forEach(function (item) {
var idValue = item;
var idCheck = Container.createSimpleBinaryExpression(expression.left, idValue,
$data.Expressions.ExpressionType.Equal, "==", "boolean", eqResolution);
if (result) {
result = Container.createSimpleBinaryExpression(result, idCheck,
$data.Expressions.ExpressionType.Or, "||", "boolean", orResolution);
} else {
result = idCheck;
};
});
var temp = context.data;
context.data = '';
this.Visit(result, context);
//context.data = temp + context.data.replace(/\(/g, '').replace(/\)/g, '');
context.data = temp + context.data;
} else {
this.Visit(expression.left, context);
context.data += " ";
context.data += expression.resolution.mapTo;
context.data += " ";
this.Visit(expression.right, context);
};
context.data += ")";
},