This is an automated email from the ASF dual-hosted git repository.

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new c05f22a0 fix(json):  JSON.ARRTRIM key no exists  (#2374)
c05f22a0 is described below

commit c05f22a0d31f069f7993f20496e1c42c9be550f7
Author: lizhenglei <[email protected]>
AuthorDate: Mon Jun 24 15:42:20 2024 +0800

    fix(json):  JSON.ARRTRIM key no exists  (#2374)
---
 src/commands/cmd_json.cc                 | 3 +--
 tests/gocase/unit/type/json/json_test.go | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/commands/cmd_json.cc b/src/commands/cmd_json.cc
index 8f788953..7708d2f8 100644
--- a/src/commands/cmd_json.cc
+++ b/src/commands/cmd_json.cc
@@ -423,8 +423,7 @@ class CommandJsonArrTrim : public Commander {
     auto s = json.ArrTrim(args_[1], path_, start_, stop_, &results);
 
     if (s.IsNotFound()) {
-      *output = conn->NilString();
-      return Status::OK();
+      return {Status::RedisExecErr, "could not perform this operation on a key 
that doesn't exist"};
     }
     if (!s.ok()) return {Status::RedisExecErr, s.ToString()};
 
diff --git a/tests/gocase/unit/type/json/json_test.go 
b/tests/gocase/unit/type/json/json_test.go
index 8182db02..e720c89b 100644
--- a/tests/gocase/unit/type/json/json_test.go
+++ b/tests/gocase/unit/type/json/json_test.go
@@ -356,7 +356,7 @@ func TestJson(t *testing.T) {
        t.Run("JSON.ARRTRIM basics", func(t *testing.T) {
                require.NoError(t, rdb.Del(ctx, "a").Err())
                // key no exists
-               require.EqualError(t, rdb.Do(ctx, "JSON.ARRTRIM", "not_exists", 
"$", 0, 0).Err(), redis.Nil.Error())
+               require.ErrorContains(t, rdb.Do(ctx, "JSON.ARRTRIM", 
"not_exists", "$", 0, 0).Err(), "could not perform this operation on a key that 
doesn't exist")
                // key not json
                require.NoError(t, rdb.Do(ctx, "SET", "no_json", "1").Err())
                require.Error(t, rdb.Do(ctx, "JSON.ARRTRIM", "no_json", "$", 0, 
0).Err())

Reply via email to