You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Send empty Array for 0 length mb replies instead of null.
This commit is contained in:
10
index.js
10
index.js
@@ -151,9 +151,11 @@ RedisReplyParser.prototype.execute = function (incoming_buf) {
|
|||||||
this.multi_bulk_length = +small_toString(this.tmp_buffer);
|
this.multi_bulk_length = +small_toString(this.tmp_buffer);
|
||||||
this.multi_bulk_replies = [];
|
this.multi_bulk_replies = [];
|
||||||
this.state = "type";
|
this.state = "type";
|
||||||
if (this.multi_bulk_length <= 0) {
|
if (this.multi_bulk_length < 0) {
|
||||||
this.send_reply(null);
|
this.send_reply(null);
|
||||||
this.multi_bulk_length = 0;
|
this.multi_bulk_length = 0;
|
||||||
|
} else if (this.multi_bulk_length === 0) {
|
||||||
|
this.send_reply([]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.emit("error", new Error("didn't see LF after NL reading multi bulk count"));
|
this.emit("error", new Error("didn't see LF after NL reading multi bulk count"));
|
||||||
@@ -347,10 +349,12 @@ Object.defineProperty(Queue.prototype, 'length', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function RedisClient(stream) {
|
function RedisClient(stream, options) {
|
||||||
events.EventEmitter.call(this);
|
events.EventEmitter.call(this);
|
||||||
|
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
|
this.options = options;
|
||||||
|
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
this.connections = 0;
|
this.connections = 0;
|
||||||
this.attempts = 1;
|
this.attempts = 1;
|
||||||
@@ -827,7 +831,7 @@ exports.createClient = function (port_arg, host_arg, options) {
|
|||||||
|
|
||||||
net_client = net.createConnection(port, host);
|
net_client = net.createConnection(port, host);
|
||||||
|
|
||||||
red_client = new RedisClient(net_client);
|
red_client = new RedisClient(net_client, options);
|
||||||
|
|
||||||
red_client.port = port;
|
red_client.port = port;
|
||||||
red_client.host = host;
|
red_client.host = host;
|
||||||
|
6
test.js
6
test.js
@@ -160,7 +160,7 @@ tests.MULTI_3 = function () {
|
|||||||
])
|
])
|
||||||
.scard("some set")
|
.scard("some set")
|
||||||
.exec(function (err, replies) {
|
.exec(function (err, replies) {
|
||||||
assert.strictEqual(replies[2][0], null, name);
|
assert.deepEqual(replies[2][0], [], name);
|
||||||
next(name);
|
next(name);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -366,7 +366,7 @@ tests.MULTIBULK_ZERO_LENGTH = function () {
|
|||||||
var name = "MULTIBULK_ZERO_LENGTH";
|
var name = "MULTIBULK_ZERO_LENGTH";
|
||||||
client.KEYS(['users:*'], function (err, results) {
|
client.KEYS(['users:*'], function (err, results) {
|
||||||
assert.strictEqual(null, err, 'error on empty multibulk reply');
|
assert.strictEqual(null, err, 'error on empty multibulk reply');
|
||||||
assert.strictEqual(null, results);
|
assert.deepEqual([], results);
|
||||||
next(name);
|
next(name);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -494,7 +494,7 @@ tests.HGETALL_NULL = function () {
|
|||||||
|
|
||||||
client.hgetall('missing', function (err, obj) {
|
client.hgetall('missing', function (err, obj) {
|
||||||
assert.strictEqual(null, err);
|
assert.strictEqual(null, err);
|
||||||
assert.strictEqual(null, obj);
|
assert.deepEqual([], obj);
|
||||||
next(name);
|
next(name);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user