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

Commit d5197aa6 by Gabe Hernandez

rebased and wrote test for pull request #265 by @mikermcneil

1 parent 281a5871
Showing with 17 additions and 1 deletions
......@@ -121,7 +121,14 @@ module.exports = (function() {
}
// options is not a hash but an id
if(typeof options === 'number') {
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') {
options = { where: options }
} else if (Utils.argsArePrimaryKeys(arguments, this.primaryKeys)) {
var where = {}
......
......@@ -300,6 +300,15 @@ describe("[" + dialect.toUpperCase() + "] DAOFactory", function() {
}.bind(this))
})
it('returns a single dao given a string id', function(done) {
this.User.find(this.user.id + '').success(function(user) {
expect(Array.isArray(user)).toBeFalsy()
expect(user.id).toEqual(this.user.id)
expect(user.id).toEqual(1)
done()
}.bind(this))
})
it("should make aliased attributes available", function(done) {
this.User.find({
where: { id: 1 },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!