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

Commit a748db3c by Sascha Depold

better array usage for utils.format

1 parent d0a4b58b
...@@ -30,7 +30,10 @@ var Utils = module.exports = { ...@@ -30,7 +30,10 @@ var Utils = module.exports = {
return client.escape(s) return client.escape(s)
}, },
format: function(arr) { format: function(arr) {
return client.format.apply(client, arr) var query = arr[0]
, replacements = Utils._.compact(arr.map(function(obj) { return obj != query ? obj : null}))
return client.format.apply(client, [query, replacements])
}, },
isHash: function(obj) { isHash: function(obj) {
return (typeof obj == 'object') && !obj.hasOwnProperty('length') return (typeof obj == 'object') && !obj.hasOwnProperty('length')
......
...@@ -92,6 +92,15 @@ module.exports = { ...@@ -92,6 +92,15 @@ module.exports = {
}) })
}) })
}, },
'findAll should work with array usage': function(exit) {
initUsers(2, function(lastUser, User) {
User.findAll({where: ['id = ?', lastUser.id]}).on('success', function(users) {
assert.eql(users.length, 1)
assert.eql(users[0].id, lastUser.id)
exit(function(){})
})
})
},
'findAll should return the correct order when order is passed': function(exit) { 'findAll should return the correct order when order is passed': function(exit) {
initUsers(2, function(lastUser, User) { initUsers(2, function(lastUser, User) {
User.findAll({order: "id DESC"}).on('success', function(users) { User.findAll({order: "id DESC"}).on('success', function(users) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!