Skip to content

Commit

Permalink
fix(schema): make clone() copy query helpers correctly
Browse files Browse the repository at this point in the history
Fix #5752
  • Loading branch information
vkarpov15 committed Oct 30, 2017
1 parent 43fb086 commit f43a984
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,13 @@ Schema.prototype.tree;
Schema.prototype.clone = function() {
var s = new Schema(this.paths, this.options);
// Clone the call queue
var cloneOpts = { retainKeyOrder: true };
s.callQueue = this.callQueue.map(function(f) { return f; });
s.methods = utils.clone(this.methods);
s.statics = utils.clone(this.statics);
s.methods = utils.clone(this.methods, cloneOpts);
s.statics = utils.clone(this.statics, cloneOpts);
s.query = utils.clone(this.query, cloneOpts);
s.plugins = Array.prototype.slice.call(this.plugins);
s._indexes = utils.clone(this._indexes);
s._indexes = utils.clone(this._indexes, cloneOpts);
s.s.hooks = this.s.hooks.clone();
return s;
};
Expand Down

0 comments on commit f43a984

Please sign in to comment.