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

Commit 8aa472cf by Sascha Depold

changed order of options check + check if the content of options can be an id

1 parent 2fec91ae
Showing with 10 additions and 9 deletions
......@@ -127,14 +127,7 @@ module.exports = (function() {
var primaryKeys = this.primaryKeys;
// options is not a hash but an id
if(typeof options === 'string') {
var parsedId = parseInt(options, 10);
if(!Utils._.isFinite(parsedId)) {
throw new Error('Invalid argument to find(). Must be an id or an options object.')
}
options = { where: parsedId }
}
else if(typeof options === 'number') {
if(typeof options === 'number') {
options = { where: options }
} else if (Utils._.size(primaryKeys) && Utils.argsArePrimaryKeys(arguments, primaryKeys)) {
var where = {}
......@@ -147,7 +140,15 @@ module.exports = (function() {
})
options = { where: where }
} else if((typeof options === 'object') && (options.hasOwnProperty('include'))) {
} else if ((typeof options === 'string') && (parseInt(options, 10).toString() === options)) {
var parsedId = parseInt(options, 10);
if(!Utils._.isFinite(parsedId)) {
throw new Error('Invalid argument to find(). Must be an id or an options object.')
}
options = { where: parsedId }
} else if ((typeof options === 'object') && (options.hasOwnProperty('include'))) {
var includes = options.include
hasJoin = true;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!