diff --git a/src/types/redis_string.cc b/src/types/redis_string.cc index 7a39cef6abb..f75fe6bb852 100644 --- a/src/types/redis_string.cc +++ b/src/types/redis_string.cc @@ -163,7 +163,7 @@ rocksdb::Status String::GetEx(const std::string &user_key, std::string *value, u LockGuard guard(storage_->GetLockManager(), ns_key); rocksdb::Status s = getValue(ns_key, value); - if (!s.ok() && s.IsNotFound()) return s; + if (!s.ok()) return s; std::string raw_data; Metadata metadata(kRedisString, false); diff --git a/tests/gocase/unit/type/strings/strings_test.go b/tests/gocase/unit/type/strings/strings_test.go index ac36fa5aef8..4b7bf4b28d4 100644 --- a/tests/gocase/unit/type/strings/strings_test.go +++ b/tests/gocase/unit/type/strings/strings_test.go @@ -241,6 +241,14 @@ func TestString(t *testing.T) { util.ErrorRegexp(t, rdb.Do(ctx, "getex").Err(), ".*wrong number of arguments*.") }) + t.Run("GETEX against wrong type", func(t *testing.T) { + rdb.Del(ctx, "foo") + rdb.LPush(ctx, "foo", "bar") + util.ErrorRegexp(t, rdb.Do(ctx, "getex", "foo").Err(), ".*WRONGTYPE.*") + require.EqualValues(t, 1, rdb.Exists(ctx, "foo").Val()) + require.Equal(t, "list", rdb.Type(ctx, "foo").Val()) + }) + t.Run("GETDEL command", func(t *testing.T) { require.NoError(t, rdb.Del(ctx, "foo").Err()) require.NoError(t, rdb.Set(ctx, "foo", "bar", 0).Err())