1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

bug(hset): make hrandfield reply match Redis (#2266)

fixes #2249
This commit is contained in:
Yue Li 2023-12-06 11:20:02 -08:00 committed by GitHub
parent 1037f446a2
commit bf0f7ec234
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1141,9 +1141,16 @@ void HSetFamily::HRandField(CmdArgList args, ConnectionContext* cntx) {
auto* rb = static_cast<RedisReplyBuilder*>(cntx->reply_builder());
OpResult<StringVec> result = cntx->transaction->ScheduleSingleHopT(std::move(cb));
if (result) {
rb->SendStringArr(*result);
if ((result->size() == 1) && (args.size() == 1))
rb->SendBulkString(result->front());
else {
rb->SendStringArr(*result, facade::RedisReplyBuilder::MAP);
}
} else if (result.status() == OpStatus::KEY_NOTFOUND) {
rb->SendNull();
if (args.size() == 1)
rb->SendNull();
else
rb->SendEmptyArray();
} else {
rb->SendError(result.status());
}