DATAREDIS-1222 - Fix limit parameter in DefaultStringRedisConnection#zRangeByLex(String,Range,Limit)
Original Pull Request: #564
This commit is contained in:
committed by
Christoph Strobl
parent
ca2403b99a
commit
f0d33077b6
@@ -68,6 +68,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Mark Paluch
|
||||
* @author Ninad Divadkar
|
||||
* @author Tugdual Grall
|
||||
* @author Andrey Shlykov
|
||||
*/
|
||||
public class DefaultStringRedisConnection implements StringRedisConnection, DecoratedRedisConnection {
|
||||
|
||||
@@ -3607,7 +3608,7 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
|
||||
*/
|
||||
@Override
|
||||
public Set<String> zRangeByLex(String key, Range range) {
|
||||
return zRangeByLex(key, range, null);
|
||||
return zRangeByLex(key, range, Limit.unlimited());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3616,7 +3617,7 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
|
||||
*/
|
||||
@Override
|
||||
public Set<String> zRangeByLex(String key, Range range, Limit limit) {
|
||||
return convertAndReturn(delegate.zRangeByLex(serialize(key), range), byteSetToStringSet);
|
||||
return convertAndReturn(delegate.zRangeByLex(serialize(key), range, limit), byteSetToStringSet);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.util.Assert;
|
||||
* @author Christoph Strobl
|
||||
* @author Clement Ong
|
||||
* @author Mark Paluch
|
||||
* @author Andrey Shlykov
|
||||
* @since 2.0
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@@ -862,7 +863,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
||||
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
if (limit != null) {
|
||||
if (limit != null && !limit.isUnlimited()) {
|
||||
pipeline(connection.newJedisResult(
|
||||
connection.getRequiredPipeline().zrangeByLex(key, min, max, limit.getOffset(), limit.getCount())));
|
||||
} else {
|
||||
@@ -872,7 +873,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
||||
}
|
||||
|
||||
if (isQueueing()) {
|
||||
if (limit != null) {
|
||||
if (limit != null && !limit.isUnlimited()) {
|
||||
transaction(connection.newJedisResult(
|
||||
connection.getRequiredTransaction().zrangeByLex(key, min, max, limit.getOffset(), limit.getCount())));
|
||||
} else {
|
||||
|
||||
@@ -62,6 +62,7 @@ import org.springframework.data.redis.connection.RedisStreamCommands.XClaimOptio
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.BitOperation;
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Range;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
|
||||
import org.springframework.data.redis.connection.SortParameters.Order;
|
||||
@@ -100,6 +101,7 @@ import org.springframework.test.annotation.ProfileValueSourceConfiguration;
|
||||
* @author Mark Paluch
|
||||
* @author Tugdual Grall
|
||||
* @author Dejan Jankov
|
||||
* @author Andrey Shlykov
|
||||
*/
|
||||
@ProfileValueSourceConfiguration(RedisTestProfileValueSource.class)
|
||||
public abstract class AbstractConnectionIntegrationTests {
|
||||
@@ -2305,7 +2307,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test // DATAREDIS-378
|
||||
@Test // DATAREDIS-378, DATAREDIS-1222
|
||||
@IfProfileValue(name = "redisVersion", value = "2.9.0+")
|
||||
@WithRedisDriver({ RedisDriver.JEDIS, RedisDriver.LETTUCE })
|
||||
public void zRangeByLexTest() {
|
||||
@@ -2323,6 +2325,10 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
actual.add(connection.zRangeByLex("myzset", Range.range().gte("aaa").lt("g")));
|
||||
actual.add(connection.zRangeByLex("myzset", Range.range().gte("e")));
|
||||
|
||||
actual.add(connection.zRangeByLex("myzset", Range.range().lte("c"), Limit.unlimited()));
|
||||
actual.add(connection.zRangeByLex("myzset", Range.range().lte("c"), Limit.limit().count(1)));
|
||||
actual.add(connection.zRangeByLex("myzset", Range.range().lte("c"), Limit.limit().count(1).offset(1)));
|
||||
|
||||
List<Object> results = getResults();
|
||||
|
||||
Set<String> values = (Set<String>) results.get(7);
|
||||
@@ -2341,6 +2347,18 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
values = (Set<String>) results.get(10);
|
||||
assertThat(values).contains("e", "f", "g");
|
||||
assertThat(values).doesNotContain("a", "b", "c", "d");
|
||||
|
||||
values = (Set<String>) results.get(11);
|
||||
assertThat(values).contains("a", "b", "c");
|
||||
assertThat(values).doesNotContain("d", "e", "f", "g");
|
||||
|
||||
values = (Set<String>) results.get(12);
|
||||
assertThat(values).contains("a");
|
||||
assertThat(values).doesNotContain("b", "c", "d", "e", "f", "g");
|
||||
|
||||
values = (Set<String>) results.get(13);
|
||||
assertThat(values).contains("b");
|
||||
assertThat(values).doesNotContain("a", "c", "d", "e", "f", "g");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREDIS-316, DATAREDIS-692
|
||||
|
||||
Reference in New Issue
Block a user