不要怂,就是干,撸起袖子干!

Commit 3ef54244 by Jochem Maas

improve option handling ("deep" clone of the *where* property) in findAndCountAl…

…l() so that generating the "count" query does not break the generated "select" query (due to the query generator overwriting the options *where* property, e.g. from `["name LIKE ?", "foo%"]` to `["foo%"]`)
1 parent 91b2be7f
Showing with 27 additions and 7 deletions
......@@ -250,14 +250,34 @@ module.exports = (function() {
}
DAOFactory.prototype.findAndCountAll = function(options) {
var self = this
, copts = Utils._.extend({}, options || {})
// this 'options cloner' is a bit hacky, should probably
// be somewhere more central -- we essentailly need this
// because in certain cases the "where" property of an options
// object is clobbered (shallow clone does not help) by a method named
// "getWhereConditions" (I think)
var clone = function(v, repls) {
if (Utils._.isObject(v)) {
v = Utils._.clone(v);
if (Utils._.isObject(v.where))
v.where = Utils._.clone(v.where);
}
// no limit, offset, order or include for the options given to count()
copts.offset = 0;
copts.limit = 0;
copts.order = null;
copts.include = null;
if (Utils._.isObject(repls))
v = Utils._.extend({}, v || {}, repls);
return v;
};
var self = this
, opts = clone(options)
, copts = clone(options, {
// no limit, offset, order or include for the options given to count()
offset : 0,
limit : 0,
order : null,
include : null
})
return new Utils.CustomEventEmitter(function (emitter) {
var emit = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!