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

Commit 87358fae by Mick Hansen

Merge pull request #4676 from treythomas123/master

Remove usage of "limit" in some places where it's unnecessary
2 parents 1c72bc93 3aea0ae9
Showing with 8 additions and 10 deletions
# Next # Next
- [Fixed] Mark postgres connection as invalid if the connection is reset [#4661](https://github.com/sequelize/sequelize/pull/4661) - [Fixed] Mark postgres connection as invalid if the connection is reset [#4661](https://github.com/sequelize/sequelize/pull/4661)
- [FIXED] Remove usage of "limit" in cases where it's unnecessary, which fixes some of the cases mentioned in [#4404] (https://github.com/sequelize/sequelize/issues/4404)
# 3.12.0 # 3.12.0
- [ADDED] Preliminary support for `include.on`. - [ADDED] Preliminary support for `include.on`.
......
...@@ -729,7 +729,6 @@ Instance.prototype.save = function(options) { ...@@ -729,7 +729,6 @@ Instance.prototype.save = function(options) {
Instance.prototype.reload = function(options) { Instance.prototype.reload = function(options) {
options = _.defaults({}, options, { options = _.defaults({}, options, {
where: this.where(), where: this.where(),
limit: 1,
include: this.$options.include || null include: this.$options.include || null
}); });
......
...@@ -1440,19 +1440,19 @@ Model.$findSeparate = function(results, options) { ...@@ -1440,19 +1440,19 @@ Model.$findSeparate = function(results, options) {
}; };
/** /**
* Search for a single instance by its primary key. This applies LIMIT 1, so the listener will always be called with a single instance. * Search for a single instance by its primary key.
* *
* @param {Number|String|Buffer} [options] A hash of options to describe the scope of the search, or a number to search by id. * @param {Number|String|Buffer} id The value of the desired instance's primary key.
* @param {Object} ' [options] * @param {Object} [options]
* @param {Transaction} [options.transaction] Transaction to run query under * @param {Transaction} [options.transaction] Transaction to run query under
* @param {String} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only) * @param {String} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only)
* *
* @see {Model#findAll} for an explanation of options * @see {Model#findAll} for a full explanation of options
* @return {Promise<Instance>} * @return {Promise<Instance>}
* @alias findByPrimary * @alias findByPrimary
*/ */
Model.prototype.findById = function(param, options) { Model.prototype.findById = function(param, options) {
// For sanity findById will never return if no options are passed // return Promise resolved with null if no arguments are passed
if ([null, undefined].indexOf(param) !== -1) { if ([null, undefined].indexOf(param) !== -1) {
return Promise.resolve(null); return Promise.resolve(null);
} }
...@@ -1466,10 +1466,8 @@ Model.prototype.findById = function(param, options) { ...@@ -1466,10 +1466,8 @@ Model.prototype.findById = function(param, options) {
throw new Error('Argument passed to findById is invalid: '+param); throw new Error('Argument passed to findById is invalid: '+param);
} }
// Bypass a possible overloaded findAll. // Bypass a possible overloaded findOne
return Model.prototype.findAll.call(this, _.defaults(options, { return Model.prototype.findOne.call(this, options);
plain: true
}));
}; };
Model.prototype.findByPrimary = Model.prototype.findById; Model.prototype.findByPrimary = Model.prototype.findById;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!