diff --git a/src/database/redis/hash.js b/src/database/redis/hash.js index 9cf320fb3d..1a9388f0a2 100644 --- a/src/database/redis/hash.js +++ b/src/database/redis/hash.js @@ -102,7 +102,7 @@ module.exports = function (redisClient, module) { module.deleteObjectField = function (key, field, callback) { callback = callback || function () {}; - if (field === null) { + if (key === undefined || key === null || field === undefined || field === null) { return setImmediate(callback); } redisClient.hdel(key, field, function (err) { diff --git a/test/database/hash.js b/test/database/hash.js index 0f8f3d0cc6..3eb84c693b 100644 --- a/test/database/hash.js +++ b/test/database/hash.js @@ -330,6 +330,34 @@ describe('Hash methods', function () { }); }); }); + + it('should not error if key is undefined', function (done) { + db.deleteObjectField(undefined, 'someField', function (err) { + assert.ifError(err); + done(); + }); + }); + + it('should not error if key is null', function (done) { + db.deleteObjectField(null, 'someField', function (err) { + assert.ifError(err); + done(); + }); + }); + + it('should not error if field is undefined', function (done) { + db.deleteObjectField('someKey', undefined, function (err) { + assert.ifError(err); + done(); + }); + }); + + it('should not error if field is null', function (done) { + db.deleteObjectField('someKey', null, function (err) { + assert.ifError(err); + done(); + }); + }); }); describe('incrObjectField()', function () {