mapleFU commented on code in PR #1837:
URL: https://github.com/apache/kvrocks/pull/1837#discussion_r1365497747


##########
src/commands/cmd_json.cc:
##########
@@ -52,7 +52,35 @@ class CommandJsonGet : public Commander {
   }
 };
 
+class CommandJsonArrAppend : public Commander {
+ public:
+  Status Execute(Server *svr, Connection *conn, std::string *output) override {
+    redis::Json json(svr->storage, conn->GetNamespace());
+
+    std::vector<uint64_t> result_count;
+
+    auto s = json.ArrAppend(args_[1], args_[2], {args_.begin() + 3, 
args_.end()}, &result_count);
+    if (!s.ok()) return {Status::RedisExecErr, s.ToString()};
+
+    if (result_count.empty()) {

Review Comment:
   ```
       r.assertOk(r.execute_command('JSON.SET', 'doc1', '$', 
json.dumps(types_data)))
       res = r.execute_command('JSON.GET', 'doc1', '$')
       r.assertEqual([types_data], json.loads(res))
   
       r.assertEqual(r.execute_command('HSET', 'hash_key', 'a', '1', 'b', '2'), 
2)
   
       # Notice: redis client is parsing error responses and trimming prefixes 
such as 'ERR'
   
       # ARRAPPEND
       r.assertEqual(r.execute_command('JSON.ARRAPPEND', 'doc1', '$.string', 
'"abc"'), [None])
       r.assertEqual(r.execute_command('JSON.ARRAPPEND', 'doc1', '$.nowhere', 
'"abc"'), [])
       r.expect('JSON.ARRAPPEND', 'doc_none', '$.string', 
'"abc"').raiseError().contains("doesn't exist")
       r.expect('JSON.ARRAPPEND', 'hash_key', '$.string', 
'"abc"').raiseError().contains("wrong Redis type")
   ```
   
   
https://github.com/RedisJSON/RedisJSON/blob/master/tests/pytest/test_multi.py#L1029-L1039
   
   Though we don't need to compatible with RedisJson( I don't think we need to 
return same error code, lol), but seems that it return the empty when nothing 
has matched.



-- 
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