Skip to content

Commit

Permalink
Fix SELECT command in Pipeline (#3301)
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Feb 27, 2023
1 parent eb0fa1d commit 84d0aaa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/redis/clients/jedis/Pipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -4272,7 +4272,7 @@ public Response<List<String>> time() {

@Override
public Response<String> select(final int index) {
return appendCommand(new CommandObject<>(commandObjects.commandArguments(Protocol.Command.SELECT), BuilderFactory.STRING));
return appendCommand(new CommandObject<>(commandObjects.commandArguments(Protocol.Command.SELECT).add(index), BuilderFactory.STRING));
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/redis/clients/jedis/PipeliningTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,13 @@ private void verifyHasBothValues(byte[] firstKey, byte[] secondKey, byte[] value

@Test
public void pipelineSelect() {
jedis.set("foo", "bar");
jedis.swapDB(0, 1);
Pipeline p = jedis.pipelined();
p.get("foo");
p.select(1);
p.sync();
p.get("foo");
assertEquals(Arrays.<Object>asList(null, "OK", "bar"), p.syncAndReturnAll());
}

@Test
Expand Down

0 comments on commit 84d0aaa

Please sign in to comment.