Skip to content

Commit

Permalink
fix(json): JSON.ARRTRIM key no exists (#2374)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyyyyyssss committed Jun 24, 2024
1 parent 92df2b8 commit c05f22a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/commands/cmd_json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()};

Expand Down
2 changes: 1 addition & 1 deletion tests/gocase/unit/type/json/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit c05f22a

Please sign in to comment.