git-hulk commented on code in PR #2336:
URL: https://github.com/apache/kvrocks/pull/2336#discussion_r1617045839


##########
src/commands/cmd_json.cc:
##########
@@ -559,9 +561,11 @@ class CommandJsonStrLen : public Commander {
 
     Optionals<uint64_t> results;
     auto s = json.StrLen(args_[1], path, &results);
-    if (s.IsNotFound()) {
+    if (s.IsNotFound() && args_.size() == 2) {
       *output = conn->NilString();
       return Status::OK();
+    } else if (s.IsNotFound() && args_.size() == 3) {
+      return {Status::RedisExecErr, "could not perform this operation on a key 
that doesn't exist"};
     }

Review Comment:
   ```suggestion
       if (s.IsNotFound()) {
         if (args_.size() == 2) {
           *output = conn->NilString();
           return Status::OK();
         } else {
           return {Status::RedisExecErr, "could not perform this operation on a 
key that doesn't exist"};
         }
       }
   ```



##########
src/commands/cmd_json.cc:
##########
@@ -382,9 +382,11 @@ class CommandJsonObjLen : public Commander {
 
     Optionals<uint64_t> results;
     auto s = json.ObjLen(args_[1], path, &results);
-    if (s.IsNotFound()) {
+    if (s.IsNotFound() && args_.size() == 2) {
       *output = conn->NilString();
       return Status::OK();
+    } else if (s.IsNotFound() && args_.size() == 3) {
+      return {Status::RedisExecErr, "Path '" + args_[2] + "' does not exist or 
not an object"};
     }

Review Comment:
   ```suggestion
       if (s.IsNotFound()) {
         if (args_.size() == 2) {
           *output = conn->NilString();
           return Status::OK();
         } else {
           return {Status::RedisExecErr, "Path '" + args_[2] + "' does not 
exist or not an object"};
         }
       }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to