Commit 3a9f41ad authored by Glenn Nethercutt's avatar Glenn Nethercutt Committed by antirez
Browse files

uphold the smove contract to return 0 when the element is not a member of the...

uphold the smove contract to return 0 when the element is not a member of the source set, even if source=dest
parent 08d4df8d
......@@ -321,7 +321,10 @@ void smoveCommand(redisClient *c) {
/* If srcset and dstset are equal, SMOVE is a no-op */
if (srcset == dstset) {
addReply(c,shared.cone);
if (setTypeIsMember(srcset,ele))
addReply(c,shared.cone);
else
addReply(c,shared.czero);
return;
}
......
......@@ -450,6 +450,7 @@ start_server {
test "SMOVE non existing key" {
setup_move
assert_equal 0 [r smove myset1 myset2 foo]
assert_equal 0 [r smove myset1 myset1 foo]
assert_equal {1 a b} [lsort [r smembers myset1]]
assert_equal {2 3 4} [lsort [r smembers myset2]]
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment