From e4aa38f1597df82be272047d91506d333d6cf409 Mon Sep 17 00:00:00 2001 From: rr- Date: Mon, 24 Apr 2017 22:09:36 +0200 Subject: [PATCH] server/search: fix errors on negative page offsets --- server/szurubooru/search/executor.py | 4 ++++ .../tests/search/configs/test_user_search_config.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/szurubooru/search/executor.py b/server/szurubooru/search/executor.py index bdb5e945..ee1cedf5 100644 --- a/server/szurubooru/search/executor.py +++ b/server/szurubooru/search/executor.py @@ -84,6 +84,10 @@ class Executor: search_query = self.parser.parse(query_text) self.config.on_search_query_parsed(search_query) + if offset < 0: + limit = max(0, limit + offset) + offset = 0 + disable_eager_loads = False for token in search_query.sort_tokens: if token.name == 'random': diff --git a/server/szurubooru/tests/search/configs/test_user_search_config.py b/server/szurubooru/tests/search/configs/test_user_search_config.py index 475b6b23..c4d9402a 100644 --- a/server/szurubooru/tests/search/configs/test_user_search_config.py +++ b/server/szurubooru/tests/search/configs/test_user_search_config.py @@ -155,7 +155,8 @@ def test_combining_tokens( (0, 1, 2, ['u1']), (1, 1, 2, ['u2']), (2, 1, 2, []), - (-1, 1, 2, ['u1']), + (-1, 1, 2, []), + (-1, 2, 2, ['u1']), (0, 2, 2, ['u1', 'u2']), (3, 1, 2, []), (0, 0, 2, []),