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

Commit b95e8d61 by Ruben Bridgewater

Hotfix

1 parent 61713712
Showing with 9 additions and 4 deletions
......@@ -700,7 +700,7 @@ module.exports = (function() {
*/
Model.prototype.findAll = function(options) {
if (options !== undefined && !_.isPlainObject(options)) {
throw new Error('The argument passed to findOne / findAll must be an options object, use findById if you wish to pass a single primary key value');
throw new Error('The argument passed to findAll must be an options object, use findById if you wish to pass a single primary key value');
}
// TODO: Remove this in the next major version (4.0)
if (arguments.length > 1) {
......@@ -709,7 +709,7 @@ module.exports = (function() {
var tableNames = {};
tableNames[this.getTableName(options)] = true;
options = optClone(options || {});
options = optClone(options);
_.defaults(options, { hooks: true });
......@@ -811,7 +811,10 @@ module.exports = (function() {
* @alias find
*/
Model.prototype.findOne = function(options) {
options = optClone(options || {});
if (options !== undefined && !_.isPlainObject(options)) {
throw new Error('The argument passed to findOne must be an options object, use findById if you wish to pass a single primary key value');
}
options = optClone(options);
if (options.limit === undefined && !(options.where && options.where[this.primaryKeyAttribute])) {
options.limit = 1;
......@@ -922,7 +925,9 @@ module.exports = (function() {
* @alias findAndCountAll
*/
Model.prototype.findAndCount = function(findOptions) {
findOptions = findOptions || {};
if (findOptions !== undefined && !_.isPlainObject(findOptions)) {
throw new Error('The argument passed to findAndCount must be an options object, use findById if you wish to pass a single primary key value');
}
var self = this
// no limit, offset, order, attributes for the options given to count()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!