# HG changeset patch # User Marcin Kuzminski # Date 2019-12-26 18:05:36 # Node ID 5c498811ff89f0d78f4763d9e6210b54b3e421c5 # Parent 2517902972d30f206d0c640f80368d058e5e7952 pagination: handle empty sets of data in sqlPaginator for backward compat. diff --git a/rhodecode/lib/pagination.py b/rhodecode/lib/pagination.py --- a/rhodecode/lib/pagination.py +++ b/rhodecode/lib/pagination.py @@ -911,6 +911,10 @@ class SqlalchemyOrmWrapper(object): return self.collection[range] def __len__(self): + # support empty types, without actually making a query. + if self.collection is None or self.collection == []: + return 0 + # Count the number of objects in an sqlalchemy.orm.query.Query object return self.collection.count()