From 8b542005c6aeb5c42f8895638798e3e450f35c76 Mon Sep 17 00:00:00 2001 From: mwish Date: Sun, 22 Oct 2023 09:02:06 +0800 Subject: [PATCH] JSON: Fix arity of JSON.SET (#1849) Co-authored-by: Twice --- src/commands/cmd_json.cc | 2 +- tests/gocase/unit/type/json/json_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/cmd_json.cc b/src/commands/cmd_json.cc index 2c0fb0c68e3..6b5445c7f03 100644 --- a/src/commands/cmd_json.cc +++ b/src/commands/cmd_json.cc @@ -148,7 +148,7 @@ class CommandJsonType : public Commander { } }; -REDIS_REGISTER_COMMANDS(MakeCmdAttr("json.set", -3, "write", 1, 1, 1), +REDIS_REGISTER_COMMANDS(MakeCmdAttr("json.set", 4, "write", 1, 1, 1), MakeCmdAttr("json.get", -2, "read-only", 1, 1, 1), MakeCmdAttr("json.type", -2, "read-only", 1, 1, 1), MakeCmdAttr("json.arrappend", -4, "write", 1, 1, 1), ); diff --git a/tests/gocase/unit/type/json/json_test.go b/tests/gocase/unit/type/json/json_test.go index b86e343fc4f..5a60ee0295d 100644 --- a/tests/gocase/unit/type/json/json_test.go +++ b/tests/gocase/unit/type/json/json_test.go @@ -37,6 +37,7 @@ func TestJson(t *testing.T) { defer func() { require.NoError(t, rdb.Close()) }() t.Run("JSON.SET and JSON.GET basics", func(t *testing.T) { + require.Error(t, rdb.Do(ctx, "JSON.SET", "a").Err()) require.NoError(t, rdb.Do(ctx, "JSON.SET", "a", "$", ` {"x":1, "y":2} `).Err()) require.Equal(t, rdb.Do(ctx, "JSON.GET", "a").Val(), `{"x":1,"y":2}`)