Allow negated has:* searches.

Before this change, we were incorrectly trying to do local
filtering on negated has searches.

(imported from commit d1a6f1feef6b3cc1c984eb91a73cd16c4e66874e)
This commit is contained in:
Steve Howell
2014-03-12 11:28:08 -04:00
parent d6617a991c
commit dfc34eb074
2 changed files with 10 additions and 2 deletions

View File

@@ -311,7 +311,7 @@ Filter.prototype = {
has_operator: function Filter_has_operator(operator) {
return _.any(this._operators, function (elem) {
if (elem.negated && (elem.operator !== 'search')) {
if (elem.negated && (!_.contains(['search', 'has'], elem.operator))) {
return false;
}
return elem.operator === operator;

View File

@@ -78,7 +78,15 @@ function assert_same_operators(result, terms) {
];
filter = new Filter(operators);
assert(filter.has_operator('search'));
assert(! filter.can_apply_locally());
assert(!filter.can_apply_locally());
// Similar logic applies to negated "has" searches.
operators = [
{operator: 'has', operand: 'images', negated: true}
];
filter = new Filter(operators);
assert(filter.has_operator('has'));
assert(!filter.can_apply_locally());
}());
(function test_new_style_operators() {