Skip to content

Commit

Permalink
Fix callback argument for a find that has no results
Browse files Browse the repository at this point in the history
  • Loading branch information
maritz committed Jan 25, 2012
1 parent 7b35536 commit 0ac4993
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/retrieve.js
Expand Up @@ -80,8 +80,10 @@ exports.find = function find(searches, callback) {
found.push(val);
}
});
} else if ( ! Array.isArray(values)) {
} else if ( ! Array.isArray(values) && values !== null) {
found = [values];
} else if (values === null) {
found = [];
}
convertIdsToInt(found, function (ids) {
callback.call(self, err, ids);
Expand Down Expand Up @@ -263,4 +265,4 @@ var sortScored = function (client, zset_key, direction, start, stop, callback) {
start, stop],
callback
);
};
};
14 changes: 13 additions & 1 deletion test/findTests.js
Expand Up @@ -633,6 +633,18 @@ loadArray: function (t) {
}
},

"search unique that doesn't exists": function (t) {
t.expect(2);
var test = nohm.factory('UserFindMockup');
test.find({
email: 'this_user_email_should_absolutely_not_exist. it\'s not even a valid email...'
}, function (err, ids) {
t.ok(!err, 'There was an error while searching an inexistant unique value.');
t.same([], ids, 'The return of a search that didn\'t find anything was wrong.');
t.done();
})
},

sort: {

"all by name": function (t) {
Expand Down Expand Up @@ -888,4 +900,4 @@ loadArray: function (t) {
});
}
}
};
};

0 comments on commit 0ac4993

Please sign in to comment.