Edgewall Software
Modify

Opened 16 years ago

Closed 16 years ago

#7113 closed defect (fixed)

TicketQuery limit argument inserts LIMIT as unicode

Reported by: aaron@… Owned by: Christian Boos
Priority: normal Milestone: 0.11
Component: ticket system Version: 0.11b2
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Using Trac 0.11b2 on Fedora 7, python 2.4.

Using the following macro on the WikiStart page

[[TicketQuery(resolution=invalid&limit=1)]]

produces an SQL error from unicode in the SQL:

# Error
Error: Macro TicketQuery(resolution=invalid&limit=1) failed

1064You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' at line 6

# SQL
...
WHERE COALESCE(t.resolution,”)=u'invalid'
ORDER BY COALESCE(t.priority,”)=”,priority.value,t.id
LIMIT u'1'

Attachments (0)

Change History (3)

comment:1 by Tim Hatch, 16 years ago

Milestone: 0.11
Priority: lownormal
Version: 0.11b2

This is an issue with mysqldb 1.2.2, but not pysqlite 2.4.1. The reporter is correct in that the following does not trigger the error:

Index: trac/ticket/query.py
===================================================================
--- trac/ticket/query.py	(revision 6814)
+++ trac/ticket/query.py	(working copy)
@@ -464,7 +464,7 @@
         # Limit number of records
         if self.limit:
             sql.append("\nLIMIT %s")
-            args.append(self.limit)       
+            args.append(int(self.limit)) 
 
         return "".join(sql), args

A quick glance doesn't show any other numeric parameters in the TicketQuery macro

comment:2 by Christian Boos, 16 years ago

Status: newassigned

comment:3 by Christian Boos, 16 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r6831. Better handle limit as an int from the start. Otherwise we risk to have surprises, like in the above code, possibly ending up with a LIMIT 0 in the SQL.

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.