Edgewall Software

Opened 6 years ago

Last modified 7 months ago

#12969 new defect

query paging problem when num_items <= max and page > 1 — at Initial Version

Reported by: cauly@… Owned by:
Priority: normal Milestone: next-stable-1.6.x
Component: query system Version:
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

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.

        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):
                raise TracError(_("Page %(page)s is beyond the number of "
                                  "pages in the query", page=self.page))

Change History (0)

Note: See TracTickets for help on using tickets.