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

Commit 72d813b6 by Chocobozzz Committed by Sushant

perf: remove unnecessary cloneDeep calls (#11281)

1 parent 9bc6d425
......@@ -180,7 +180,7 @@ class HasMany extends Association {
instances = undefined;
}
options = Utils.cloneDeep(options);
options = Object.assign({}, options);
if (this.scope) {
Object.assign(where, this.scope);
......
......@@ -1689,7 +1689,6 @@ class Model {
this.warnOnInvalidOptions(options, Object.keys(this.rawAttributes));
const tableNames = {};
let originalOptions;
tableNames[this.getTableName(options)] = true;
options = Utils.cloneDeep(options);
......@@ -1751,9 +1750,8 @@ class Model {
return this.runHooks('beforeFindAfterOptions', options);
}
}).then(() => {
originalOptions = Utils.cloneDeep(options);
options.tableNames = Object.keys(tableNames);
return this.QueryInterface.select(this, this.getTableName(options), options);
const selectOptions = Object.assign({}, options, { tableNames: Object.keys(tableNames) });
return this.QueryInterface.select(this, this.getTableName(selectOptions), selectOptions);
}).tap(results => {
if (options.hooks) {
return this.runHooks('afterFind', results, options);
......@@ -1771,7 +1769,7 @@ class Model {
throw new sequelizeErrors.EmptyResultError();
}
return Model._findSeparate(results, originalOptions);
return Model._findSeparate(results, options);
});
}
......
......@@ -1112,10 +1112,8 @@ class QueryInterface {
);
}
select(model, tableName, options) {
options = Utils.cloneDeep(options);
options.type = QueryTypes.SELECT;
options.model = model;
select(model, tableName, optionsArg) {
const options = Object.assign({}, optionsArg, { type: QueryTypes.SELECT, model });
return this.sequelize.query(
this.QueryGenerator.selectQuery(tableName, options, model),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!