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

Commit ee9c20e6 by Mick Hansen

fix/feat(model/find): only apply limit: 1 if not querying on primary key

1 parent 3ba08e67
Showing with 4 additions and 3 deletions
...@@ -773,13 +773,14 @@ module.exports = (function() { ...@@ -773,13 +773,14 @@ module.exports = (function() {
if (options.attributes === undefined) { if (options.attributes === undefined) {
options.attributes = Object.keys(this.rawAttributes); options.attributes = Object.keys(this.rawAttributes);
} }
mapFieldNames.call(this, options, this);
options = paranoidClause.call(this, options); if (options.limit === undefined && !options.where[this.primaryKeyAttribute]) {
if (options.limit === undefined) {
options.limit = 1; options.limit = 1;
} }
mapFieldNames.call(this, options, this);
options = paranoidClause.call(this, options);
return this.QueryInterface.select(this, this.getTableName(), options, Utils._.defaults({ return this.QueryInterface.select(this, this.getTableName(), options, Utils._.defaults({
plain: true, plain: true,
type: QueryTypes.SELECT, type: QueryTypes.SELECT,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!