Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#5049 closed enhancement (fixed)

[PATCH] TicketQuery Limit Query Results

Reported by: Karmadude <karmadude@…> Owned by: Christian Boos
Priority: normal Milestone: 0.11
Component: ticket system Version:
Severity: minor Keywords: tracquery limit
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Added functionality to limit number of records in query via the query string

Example

[[TicketQuery(version=1.0|2.0&resolution=duplicate&limit=5)]]

Attachments (2)

ticketquery_limit.patch (1.4 KB ) - added by karmadude@… 18 years ago.
TracQuery Limit Patch
ticketquery_limit2.patch (1.9 KB ) - added by karmadude@… 18 years ago.

Download all attachments as: .zip

Change History (7)

by karmadude@…, 18 years ago

Attachment: ticketquery_limit.patch added

TracQuery Limit Patch

comment:1 by Christian Boos, 18 years ago

Milestone: 0.11
Owner: changed from Jonas Borgström to Christian Boos
Severity: normalminor

Nice little patch ;-) However, the self.limit should be appended to the args list, in order to protect against SQL injections issues.

comment:2 by karmadude@…, 18 years ago

I have added an updated patch, I changed the code to match closely to how order argument is handled. Also I had to update the query call in process_request function to use the limit arg.

cobos, I am not very familiar with the Trac code, this was my first stab at a solution, and I just followed how the order arg was being handled. As for SQL injections, we have a internal deployment of Trac, and so I did not give that much thought. If you have some suggestions as to how to improve the code, I can take a stab at improving the patch.

comment:3 by Christian Boos, 18 years ago

Usually what we do is simply to dissociate the SQL statement from the arguments:

if self.limit:
    sql.append("\nLIMIT %s")
    args.append(self.limit)

and later call cursor.execute(sql, args), which takes care of using the args as arguments; otherwise you could pass arbitrary SQL in the limit query parameter.

by karmadude@…, 18 years ago

Attachment: ticketquery_limit2.patch added

comment:4 by karmadude@…, 18 years ago

cboos, thanks for explaining that to me, it all makes sense now. I have updated the patch.

comment:5 by Christian Boos, 18 years ago

Resolution: fixed
Status: newclosed

Implemented in [5149:5150]. Thanks for the patch!

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


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