Opened 15 years ago
Last modified 11 years ago
#5568 closed defect
Mysql requests issues with TracTicketStatsPlugin — at Initial Version
Reported by: | Owned by: | Prentice Wongvibulsin | |
---|---|---|---|
Priority: | normal | Component: | TracTicketStatsPlugin |
Severity: | blocker | Keywords: | mysql |
Cc: | Trac Release: | 0.11 |
Description
Hello,
I ran into SQL requests issues while running TicketStatsPlugin with a mysql backend :
1)(1054, "Unknown column 'created' in 'where clause'")
This is due to Mysql poor Alias handling, i propose to use the column name (t.time) instead of alias name(created) as shown in following patch :
ticketstats.py @@ -88,13 +88,13 @@ - cursor.execute("SELECT t.type AS type, owner, status, time AS created FROM ticket t, enum p WHERE p.name = t.priority AND p.type = 'priority' AND created <= %s" % to_timestamp(at_date)) + cursor.execute("SELECT t.type AS type, owner, status, time AS created FROM ticket t, enum p WHERE p.name = t.priority AND p.type = 'priority' AND t.time <= %s" % to_timestamp(at_date))
2) The next issue is related with the use of 'enum p' . Here comes the proposed patch :
ticketstats.py @@ -61,7 +61,7 @@ - cursor.execute("SELECT t.id, tc.field, tc.time, tc.oldvalue, tc.newvalue, t.priority FROM ticket_change tc, enum p INNER JOIN ticket t ON t.id = tc.ticket AND tc.time > %s AND tc.time <= %s WHERE p.name = t.priority AND p.type = 'priority' ORDER BY tc.time" % (to_timestamp(from_date), to_timestamp(at_date))) + cursor.execute("SELECT t.id, tc.field, tc.time, tc.oldvalue, tc.newvalue, t.priority FROM enum p, ticket_change tc INNER JOIN ticket t ON t.id = tc.ticket AND tc.time > %s AND tc.time <= %s WHERE p.name = t.priority AND p.type = 'priority' ORDER BY tc.time" % (to_timestamp(from_date), to_timestamp(at_date)))
Hope this helps. Thanks for all your good job with this plugin
Note: See
TracTickets for help on using
tickets.