From 05e96998177f7901ddf8b0d1392a0ddc6769e3cc Mon Sep 17 00:00:00 2001 From: Matt Ranney Date: Wed, 10 Nov 2010 10:36:26 -0800 Subject: [PATCH] Fix for null MULTI response when WATCH condition fails. --- README.md | 1 + changelog.md | 4 ++++ package.json | 5 +++-- test.js | 43 ++++++++++++++++++++++++++++++++----------- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index bd03d95cd7..06182e3625 100644 --- a/README.md +++ b/README.md @@ -420,6 +420,7 @@ In order of first contribution, they are: * [Orion Henry](http://github.com/orionz) * [Hank Sims](http://github.com/hanksims) * [Aivo Paas](http://github.com/aivopaas) +* [Paul Carey](https://github.com/paulcarey) Thanks. diff --git a/changelog.md b/changelog.md index f90a46dc99..5d1c9172ac 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,10 @@ Changelog ========= +## v0.3.8 - November 10, 2010 + +Fix for null MULTI response when WATCH condition fails. + ## v0.3.7 - November 9, 2010 Add "drain" and "idle" events. diff --git a/package.json b/package.json index dea4ba59d0..1682b10c57 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "name" : "redis", - "version" : "0.3.7", + "version" : "0.3.8", "description" : "Redis client library", "author": "Matt Ranney ", "contributors": [ @@ -8,7 +8,8 @@ "TJ Holowaychuk", "Orion Henry", "Hank Sims", - "Aivo Paas" + "Aivo Paas", + "Paul Carey" ], "main": "./index.js", "scripts": { diff --git a/test.js b/test.js index ec4c1e3a7c..2cd98162c3 100644 --- a/test.js +++ b/test.js @@ -6,7 +6,10 @@ var redis = require("./index"), assert = require("assert"), util, test_db_num = 15, // this DB will be flushed and used for testing - tests = {}; + tests = {}, + connected = false, + ended = false, + server_info; try { util = require("util"); @@ -207,13 +210,18 @@ tests.MULTI_6 = function () { tests.WATCH_MULTI = function () { var name = 'WATCH_MULTI'; - client.watch(name); - var multi = client.multi(); - multi.incr(name); - client.incr(name); - multi.exec(function (err, replies) { - next(name); - }); + if (server_info.versions[0] >= 2 && server_info.versions[1] >= 1) { + client.watch(name); + var multi = client.multi(); + multi.incr(name); + client.incr(name); + multi.exec(function (err, replies) { + next(name); + }); + } else { + console.log("Skipping " + name + " because server version isn't new enough."); + next(name); + } }; tests.HSET = function () { @@ -991,11 +999,24 @@ function run_next_test() { } } -var connected = false; -var ended = false; client.on("connect", function () { + // Fetch and stash info results in case anybody needs info on the server we are using. + client.info(function (err, reply) { + var obj = {}; + reply.toString().split('\n').forEach(function (line) { + var parts = line.split(':'); + if (parts[1]) { + obj[parts[0]] = parts[1]; + } + }); + obj.versions = []; + obj.redis_version.split('.').forEach(function (num) { + obj.versions.push(+num); + }); + server_info = obj; + }); + connected = true; - console.log(); run_next_test(); });