Skip to content

Commit

Permalink
allow storing null in redis
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonjs committed May 22, 2011
1 parent faa8ab9 commit 6acc1fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nconf/stores/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Redis.prototype.set = function (key, value, callback) {

var fullKey = nconf.key(self.namespace, key);

if (!Array.isArray(value) && typeof value === 'object') {
if (!Array.isArray(value) && value !== null && typeof value === 'object') {
//
// If the value is an `Object` (and not an `Array`) then
// nest into the value and set the child keys appropriately.
Expand Down
16 changes: 16 additions & 0 deletions test/redis-store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ vows.describe('nconf/stores/redis').addBatch({
"should respond without an error": function (err, ok) {
assert.isNull(err);
}
},
"with null": {
topic: function (store) {
store.set('falsy:object', null, this.callback);
},
"should respond without an error": function(err, ok) {
assert.isNull(err);
}
}
}
}
Expand Down Expand Up @@ -75,6 +83,14 @@ vows.describe('nconf/stores/redis').addBatch({
"should respond with the correct value": function (err, value) {
assert.deepEqual(value, data.obj.auth);
}
},
"with null": {
topic: function(store) {
store.get('falsy:object', this.callback);
},
"should respond with the correct value": function(err, value) {
assert.equal(value, null);
}
}
}
}
Expand Down

0 comments on commit 6acc1fc

Please sign in to comment.