Skip to content

Commit 9d96faa

Browse files
committed
Fix bug parsing results of xrange
1 parent faa51d4 commit 9d96faa

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

docs/about/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
## Next release
2+
3+
## v2.9.2
4+
### 🐛 Bug Fixes
5+
- Fix bug for `xrange`
6+
7+
28
## v2.9.1
39
### 🐛 Bug Fixes
410
- Fix bug for `xrevrange`

fakeredis/_stream.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def find_index(self, id_str: str) -> Tuple[int, bool]:
6262

6363
@staticmethod
6464
def _format_record(record):
65-
return [f'{record[0][0]}-{record[0][1]}'.encode(), list(record[1:])]
65+
results = list(record[1:][0])
66+
return [f'{record[0][0]}-{record[0][1]}'.encode(), results]
6667

6768
def trim(self,
6869
maxlen: Optional[int] = None,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ name = "fakeredis"
88
packages = [
99
{ include = "fakeredis" },
1010
]
11-
version = "2.9.1"
11+
version = "2.9.2"
1212
description = "Fake implementation of redis API for testing purposes."
1313
readme = "README.md"
1414
keywords = ["redis", "rq", "django-rq", "RedisJson", ]

test/test_mixins/test_streams_commands.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ def test_xrevrange(r: redis.Redis):
185185

186186

187187
def test_xrange(r: redis.Redis):
188+
m = r.xadd('stream1', {"foo": "bar"})
189+
assert r.xrange('stream1') == [(m, {b"foo": b"bar"}), ]
190+
191+
stream = 'stream2'
192+
m = testtools.raw_command(r, 'xadd', stream, '*', b'field', b'value', b'foo', b'bar')
193+
results = r.xrevrange(stream)
194+
195+
assert results == [(m, {b'field': b'value', b'foo': b'bar'}), ]
196+
188197
stream = "stream"
189198
m1 = r.xadd(stream, {"foo": "bar"})
190199
m2 = r.xadd(stream, {"foo": "bar"})

0 commit comments

Comments
 (0)