Commit 98cf075d authored by Marco Mariani's avatar Marco Mariani

comparisons with undefined are always false

parent 1ebfd26d
...@@ -152,6 +152,9 @@ SimpleQuery.prototype.match = function (item, wildcard_character) { ...@@ -152,6 +152,9 @@ SimpleQuery.prototype.match = function (item, wildcard_character) {
object_value = item[key]; object_value = item[key];
value = this.value; value = this.value;
} }
if (object_value === undefined || value === undefined) {
return RSVP.resolve(false);
}
return matchMethod(object_value, value, wildcard_character); return matchMethod(object_value, value, wildcard_character);
}; };
...@@ -195,15 +198,6 @@ SimpleQuery.prototype["="] = function (object_value, comparison_value, ...@@ -195,15 +198,6 @@ SimpleQuery.prototype["="] = function (object_value, comparison_value,
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (comparison_value === undefined) {
if (value === undefined) {
return RSVP.resolve(true);
}
return RSVP.resolve(false);
}
if (value === undefined) {
return RSVP.resolve(false);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value, return RSVP.resolve(value.cmp(comparison_value,
wildcard_character) === 0); wildcard_character) === 0);
...@@ -240,15 +234,6 @@ SimpleQuery.prototype["!="] = function (object_value, comparison_value, ...@@ -240,15 +234,6 @@ SimpleQuery.prototype["!="] = function (object_value, comparison_value,
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (comparison_value === undefined) {
if (value === undefined) {
return RSVP.resolve(false);
}
return RSVP.resolve(true);
}
if (value === undefined) {
return RSVP.resolve(true);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value, return RSVP.resolve(value.cmp(comparison_value,
wildcard_character) !== 0); wildcard_character) !== 0);
...@@ -282,9 +267,6 @@ SimpleQuery.prototype["<"] = function (object_value, comparison_value) { ...@@ -282,9 +267,6 @@ SimpleQuery.prototype["<"] = function (object_value, comparison_value) {
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (value === undefined || comparison_value === undefined) {
return RSVP.resolve(false);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value) < 0); return RSVP.resolve(value.cmp(comparison_value) < 0);
} }
...@@ -309,9 +291,6 @@ SimpleQuery.prototype["<="] = function (object_value, comparison_value) { ...@@ -309,9 +291,6 @@ SimpleQuery.prototype["<="] = function (object_value, comparison_value) {
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (value === undefined || comparison_value === undefined) {
return RSVP.resolve(false);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value) <= 0); return RSVP.resolve(value.cmp(comparison_value) <= 0);
} }
...@@ -336,9 +315,6 @@ SimpleQuery.prototype[">"] = function (object_value, comparison_value) { ...@@ -336,9 +315,6 @@ SimpleQuery.prototype[">"] = function (object_value, comparison_value) {
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (value === undefined || comparison_value === undefined) {
return RSVP.resolve(false);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value) > 0); return RSVP.resolve(value.cmp(comparison_value) > 0);
} }
...@@ -363,9 +339,6 @@ SimpleQuery.prototype[">="] = function (object_value, comparison_value) { ...@@ -363,9 +339,6 @@ SimpleQuery.prototype[">="] = function (object_value, comparison_value) {
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (value === undefined || comparison_value === undefined) {
return RSVP.resolve(false);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value) >= 0); return RSVP.resolve(value.cmp(comparison_value) >= 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment