From 560457337c37ceaa16baaf65b1674e83463ecc20 Mon Sep 17 00:00:00 2001 From: AvitalFineRedis Date: Thu, 11 Nov 2021 09:50:51 +0100 Subject: Support desc for 3.5.3 --- redis/commands/core.py | 4 ++++ tests/test_commands.py | 1 + 2 files changed, 5 insertions(+) diff --git a/redis/commands/core.py b/redis/commands/core.py index 90997ff..0344e3a 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -2520,6 +2520,10 @@ class CoreCommands: ``offset`` and ``num`` are specified, then return a slice of the range. Can't be provided when using ``bylex``. """ + # Supports old implementation: need to support ``desc`` also for version < 6.2.0 + if not byscore and not bylex and (offset is None and num is None) and desc: + return self.zrevrange(name, start, end, withscores, + score_cast_func) return self._zrange('ZRANGE', None, name, start, end, desc, byscore, bylex, withscores, score_cast_func, offset, num) diff --git a/tests/test_commands.py b/tests/test_commands.py index 6d4ab00..c361a4b 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1867,6 +1867,7 @@ class TestRedisCommands: assert r.zrange('a', 0, 1) == [b'a1', b'a2'] assert r.zrange('a', 1, 2) == [b'a2', b'a3'] assert r.zrange('a', 0, 2) == [b'a1', b'a2', b'a3'] + assert r.zrange('a', 0, 2, desc=True) == [b'a3', b'a2', b'a1'] # withscores assert r.zrange('a', 0, 1, withscores=True) == \ -- cgit v1.2.1