-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue #49 - $where operator is not evaluated last #50
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1327,10 +1327,16 @@ Mingo.Query.prototype = { | |
|
||
assert(isObject(this.__criteria), 'Criteria must be of type Object') | ||
|
||
var whereOperators = []; | ||
|
||
for (var field in this.__criteria) { | ||
if (has(this.__criteria, field)) { | ||
var expr = this.__criteria[field] | ||
if (inArray(['$and', '$or', '$nor', '$where'], field)) { | ||
// save $where operators to be executed after other operators | ||
if (inArray(['$where'], field)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think an equality check will do here. |
||
whereOperators.push({field: field, expr: expr}); | ||
} | ||
else if (inArray(['$and', '$or', '$nor'], field)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer the style if (<condition>) {
<statements>
} else if (<codition2>) {
... |
||
this._processOperator(field, field, expr) | ||
} else { | ||
// normalize expression | ||
|
@@ -1342,6 +1348,11 @@ Mingo.Query.prototype = { | |
} | ||
} | ||
} | ||
var self = this; | ||
console.log(whereOperators); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove debug statement |
||
whereOperators.forEach(function(where) { | ||
self._processOperator(where.field, where.field, where.expr); | ||
}); | ||
} | ||
}, | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one
$where
expression allowed in query so this can be single valued