Edgewall Software
Modify

Opened 6 years ago

Last modified 7 months ago

#12969 new defect

query paging problem when num_items <= max and page > 1

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 (last modified by anonymous)

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

Related code:

        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))

Attachments (0)

Change History (4)

comment:1 by anonymous, 6 years ago

Description: modified (diff)

comment:2 by Jun Omae, 6 years ago

Milestone: next-stable-1.2.x
Severity: normalminor

When number of the query result is less than number of max parameter are same, the page parameter is ignored.


https://trac.edgewall.org/demo-1.2/query?id=1&max=1&page=1 Ok
https://trac.edgewall.org/demo-1.2/query?id=1&max=1&page=9999 TracError should be raised
https://trac.edgewall.org/demo-1.2/query?id=1-10&max=1&page=1 Ok
https://trac.edgewall.org/demo-1.2/query?id=1-10&max=10&page=9999 TracError should be raised
Version 1, edited 6 years ago by Jun Omae (previous) (next) (diff)

comment:3 by Ryan J Ollos, 4 years ago

Milestone: next-stable-1.2.xnext-stable-1.4.x

comment:4 by Ryan J Ollos, 7 months ago

Milestone: next-stable-1.4.xnext-stable-1.6.x

Milestone renamed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.