Edgewall Software
Modify

Opened 10 months ago

Last modified 10 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.2.x
Component: query system Version:
Severity: minor Keywords:
Cc:
Release Notes:
API 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 (2)

comment:1 Changed 10 months ago by anonymous

Description: modified (diff)

comment:2 Changed 10 months ago by Jun Omae

Milestone: next-stable-1.2.x
Severity: normalminor
Last edited 10 months ago by Jun Omae (previous) (diff)

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.
The owner will be changed from (none) to anonymous.

Add Comment


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