Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix callback argument for a find that has no results

  • Loading branch information...
commit 0ac4993eee9ed2763dccd15ddda59eca8d17eab8 1 parent 7b35536
@maritz authored
Showing with 17 additions and 3 deletions.
  1. +4 −2 lib/retrieve.js
  2. +13 −1 test/findTests.js
View
6 lib/retrieve.js
@@ -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);
@@ -263,4 +265,4 @@ var sortScored = function (client, zset_key, direction, start, stop, callback) {
start, stop],
callback
);
-};
+};
View
14 test/findTests.js
@@ -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) {
@@ -888,4 +900,4 @@ loadArray: function (t) {
});
}
}
-};
+};
Please sign in to comment.
Something went wrong with that request. Please try again.