Skip to content

Commit 6acc1fc

Browse files
committed
allow storing null in redis
1 parent faa8ab9 commit 6acc1fc

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/nconf/stores/redis.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Redis.prototype.set = function (key, value, callback) {
151151

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

154-
if (!Array.isArray(value) && typeof value === 'object') {
154+
if (!Array.isArray(value) && value !== null && typeof value === 'object') {
155155
//
156156
// If the value is an `Object` (and not an `Array`) then
157157
// nest into the value and set the child keys appropriately.

test/redis-store-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ vows.describe('nconf/stores/redis').addBatch({
3737
"should respond without an error": function (err, ok) {
3838
assert.isNull(err);
3939
}
40+
},
41+
"with null": {
42+
topic: function (store) {
43+
store.set('falsy:object', null, this.callback);
44+
},
45+
"should respond without an error": function(err, ok) {
46+
assert.isNull(err);
47+
}
4048
}
4149
}
4250
}
@@ -75,6 +83,14 @@ vows.describe('nconf/stores/redis').addBatch({
7583
"should respond with the correct value": function (err, value) {
7684
assert.deepEqual(value, data.obj.auth);
7785
}
86+
},
87+
"with null": {
88+
topic: function(store) {
89+
store.get('falsy:object', this.callback);
90+
},
91+
"should respond with the correct value": function(err, value) {
92+
assert.equal(value, null);
93+
}
7894
}
7995
}
8096
}

0 commit comments

Comments
 (0)