Skip to content

Commit

Permalink
Fix #1116 - trimmed stream causes exception on xreadgroup with id 0
Browse files Browse the repository at this point in the history
messages

Signed-off-by: Xabier Eizmendi <[email protected]>
  • Loading branch information
xeizmendi committed Jan 10, 2019
1 parent a3cfded commit e5d53dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ def parse_sentinel_get_master(response):

def pairs_to_dict(response, decode_keys=False):
"Create a dict given a list of key/value pairs"
if response is None:
return {}
if decode_keys:
# the iter form is faster, but I don't know how to make that work
# with a nativestr() map
Expand Down
16 changes: 16 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,22 @@ def test_xreadgroup(self, r):
# xread starting after the last message returns an empty message list
assert r.xreadgroup(group, consumer, streams={stream: '>'}) == expected

r.xgroup_destroy(stream, group)
r.xgroup_create(stream, group, '0')
# delete all the messages in the stream
expected = [
[
stream.encode(),
[
(m1, {}),
(m2, {}),
]
]
]
r.xreadgroup(group, consumer, streams={stream: '>'})
r.xtrim(stream, 0)
assert r.xreadgroup(group, consumer, streams={stream: '0'}) == expected

@skip_if_server_version_lt('5.0.0')
def test_xrevrange(self, r):
stream = 'stream'
Expand Down

0 comments on commit e5d53dd

Please sign in to comment.