query paging problem when num_items <= max and page > 1
|Reported by:||Owned by:|
Description (last modified by )
Suppose a query generates 20 results. max=20 is specified in the query string. When page=n (n>1) is also specified, the query will always return the 20 results rather than "beyond the number of pages" Error.
It's ok with web UI, so not sure this is a bug or feature. But it does bring trouble to other components which rely on query system, such as XMLRPC plugin. Suppose you query through xmlrpc with max=20&page=1 and 20 results returned, then query with max=20&page=2 but another 20 results returned, which is not quite reasonable.
How to reproduce: Visit here: https://trac.edgewall.org/query?summary=~query+paging+problem&page=100&max=1
if self.num_items <= self.max: self.has_more_pages = False if self.has_more_pages: max = self.max if self.group: max += 1 sql += " LIMIT %d OFFSET %d" % (max, self.offset) if (self.page > int(ceil(float(self.num_items) / self.max)) and self.num_items != 0): #this should not depend of has_more_pages condition raise TracError(_("Page %(page)s is beyond the number of " "pages in the query", page=self.page))