Skip to content

Commit 5604573

Browse files
Support desc for 3.5.3
1 parent 5be96b9 commit 5604573

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

redis/commands/core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,6 +2520,10 @@ def zrange(self, name, start, end, desc=False, withscores=False,
25202520
``offset`` and ``num`` are specified, then return a slice of the range.
25212521
Can't be provided when using ``bylex``.
25222522
"""
2523+
# Supports old implementation: need to support ``desc`` also for version < 6.2.0
2524+
if not byscore and not bylex and (offset is None and num is None) and desc:
2525+
return self.zrevrange(name, start, end, withscores,
2526+
score_cast_func)
25232527
return self._zrange('ZRANGE', None, name, start, end, desc, byscore,
25242528
bylex, withscores, score_cast_func, offset, num)
25252529

tests/test_commands.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,7 @@ def test_zrange(self, r):
18671867
assert r.zrange('a', 0, 1) == [b'a1', b'a2']
18681868
assert r.zrange('a', 1, 2) == [b'a2', b'a3']
18691869
assert r.zrange('a', 0, 2) == [b'a1', b'a2', b'a3']
1870+
assert r.zrange('a', 0, 2, desc=True) == [b'a3', b'a2', b'a1']
18701871

18711872
# withscores
18721873
assert r.zrange('a', 0, 1, withscores=True) == \

0 commit comments

Comments
 (0)