Skip to content

Commit

Permalink
Address change in JSON.GET command without path (#3858)
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Jul 9, 2024
1 parent fe87260 commit 72073c5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
3 changes: 1 addition & 2 deletions src/main/java/redis/clients/jedis/CommandObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -3458,8 +3458,7 @@ public final CommandObject<String> jsonMerge(String key, Path path, Object pojo)
}

public final CommandObject<Object> jsonGet(String key) {
return new CommandObject<>(commandArguments(JsonCommand.GET).key(key),
protocol != RedisProtocol.RESP3 ? JSON_GENERIC_OBJECT : JsonBuilderFactory.JSON_OBJECT);
return new CommandObject<>(commandArguments(JsonCommand.GET).key(key), JSON_GENERIC_OBJECT);
}

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public void setUp() {

@Test
public void basicSetGetShouldSucceed() {
Assume.assumeFalse(RedisProtocolUtil.getRedisProtocol() == RedisProtocol.RESP3);

// naive set with a path
jsonV2.jsonSetWithEscape("null", ROOT_PATH, (Object) null);
assertJsonArrayEquals(jsonArray((Object) null), jsonV2.jsonGet("null", ROOT_PATH));
Expand All @@ -66,29 +64,6 @@ public void basicSetGetShouldSucceed() {
assertJsonArrayEquals(jsonArray("strung"), jsonV2.jsonGet("obj", p));
}

@Test
public void basicSetGetShouldSucceedResp3() {
Assume.assumeTrue(RedisProtocolUtil.getRedisProtocol() == RedisProtocol.RESP3);

// naive set with a path
jsonV2.jsonSetWithEscape("null", ROOT_PATH, (Object) null);
assertJsonArrayEquals(jsonArray((Object) null), jsonV2.jsonGet("null", ROOT_PATH));

// real scalar value and no path
jsonV2.jsonSetWithEscape("str", "strong");
assertJsonArrayEquals(jsonArray("strong"), jsonV2.jsonGet("str"));

// a slightly more complex object
IRLObject obj = new IRLObject();
jsonV2.jsonSetWithEscape("obj", obj);
assertJsonArrayEquals(jsonArray(new JSONObject(gson.toJson(obj))), jsonV2.jsonGet("obj"));

// check an update
Path2 p = Path2.of(".str");
jsonV2.jsonSet("obj", p, gson.toJson("strung"));
assertJsonArrayEquals(jsonArray("strung"), jsonV2.jsonGet("obj", p));
}

@Test
public void setExistingPathOnlyIfExistsShouldSucceed() {
jsonV2.jsonSetWithEscape("obj", new IRLObject());
Expand Down

0 comments on commit 72073c5

Please sign in to comment.