From cd2967d271d8127b6f6ebf4aa7a671d3eeca3c59 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 15 Aug 2014 16:05:46 +0100 Subject: [PATCH] Fix bug when generating a key when get_room_events_stream returned zero rows --- synapse/storage/stream.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py index 47f05a41b..bb56f0763 100644 --- a/synapse/storage/stream.py +++ b/synapse/storage/stream.py @@ -89,10 +89,14 @@ class StreamStore(SQLBaseStore): ret = [self._parse_event_from_row(r) for r in rows] - if from_key < to_key: - key = max([r["ordering"] for r in rows]) + + if rows: + if from_key < to_key: + key = max([r["ordering"] for r in rows]) + else: + key = min([r["ordering"] for r in rows]) else: - key = min([r["ordering"] for r in rows]) + key = to_key defer.returnValue((ret, key))