HDEL: Abort deleting fields when hash is removed
This commit is contained in:
parent
80e87a461a
commit
2d7162bb1d
@ -403,8 +403,11 @@ void hdelCommand(redisClient *c) {
|
|||||||
|
|
||||||
for (j = 2; j < c->argc; j++) {
|
for (j = 2; j < c->argc; j++) {
|
||||||
if (hashTypeDelete(o,c->argv[j])) {
|
if (hashTypeDelete(o,c->argv[j])) {
|
||||||
if (hashTypeLength(o) == 0) dbDelete(c->db,c->argv[1]);
|
|
||||||
deleted++;
|
deleted++;
|
||||||
|
if (hashTypeLength(o) == 0) {
|
||||||
|
dbDelete(c->db,c->argv[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
|
@ -235,6 +235,13 @@ start_server {tags {"hash"}} {
|
|||||||
r hgetall myhash
|
r hgetall myhash
|
||||||
} {b 2}
|
} {b 2}
|
||||||
|
|
||||||
|
test {HDEL - hash becomes empty before deleting all specified fields} {
|
||||||
|
r del myhash
|
||||||
|
r hmset myhash a 1 b 2 c 3
|
||||||
|
assert_equal 3 [r hdel myhash a b c d e]
|
||||||
|
assert_equal 0 [r exists myhash]
|
||||||
|
}
|
||||||
|
|
||||||
test {HEXISTS} {
|
test {HEXISTS} {
|
||||||
set rv {}
|
set rv {}
|
||||||
set k [lindex [array names smallhash *] 0]
|
set k [lindex [array names smallhash *] 0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user