diff --git a/server/szurubooru/search/search_executor.py b/server/szurubooru/search/search_executor.py index 1f58007..8cbd6c3 100644 --- a/server/szurubooru/search/search_executor.py +++ b/server/szurubooru/search/search_executor.py @@ -46,6 +46,7 @@ class SearchExecutor(object): query = self._handle_anonymous( query, self._create_criterion(token, negated)) + query = self._search_config.finalize_query(query) return query def _handle_key_value(self, query, key, value, negated): diff --git a/server/szurubooru/search/user_search_config.py b/server/szurubooru/search/user_search_config.py index 4b394ad..589e1d5 100644 --- a/server/szurubooru/search/user_search_config.py +++ b/server/szurubooru/search/user_search_config.py @@ -8,6 +8,9 @@ class UserSearchConfig(BaseSearchConfig): def create_query(self, session): return session.query(db.User) + def finalize_query(self, query): + return query.order_by(db.User.name.asc()) + @property def anonymous_filter(self): return self._create_basic_filter(db.User.name, allow_ranged=False) diff --git a/server/szurubooru/tests/search/test_user_search_config.py b/server/szurubooru/tests/search/test_user_search_config.py index 9f3d472..0cc6c1d 100644 --- a/server/szurubooru/tests/search/test_user_search_config.py +++ b/server/szurubooru/tests/search/test_user_search_config.py @@ -124,8 +124,9 @@ class TestUserSearchExecutor(DatabaseTestCase): self._test('', 2, 1, 2, ['u2']) def test_order_by_name(self): - self.session.add(util.mock_user('u1')) self.session.add(util.mock_user('u2')) + self.session.add(util.mock_user('u1')) + self._test('', 1, 100, 2, ['u1', 'u2']) self._test('order:name', 1, 100, 2, ['u1', 'u2']) self._test('-order:name', 1, 100, 2, ['u2', 'u1']) self._test('order:name,asc', 1, 100, 2, ['u1', 'u2'])