Opened 18 years ago
Closed 16 years ago
#6319 closed defect (worksforme)
Literal '%' gets duplicated in report with $VARIABLE replacement
| Reported by: | Owned by: | Matthew Good | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | report system | Version: | devel | 
| Severity: | normal | Keywords: | verify | 
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
I'm using the reporting engine to generate some summaries for milestones and I'm generating a percentage and wanted to concat a '%' character to my percentage. Fairly Standard. This works fine until I use a parameter to the report to customize it, at which point the '%' gets duplicated.
No doubt this is an attempt somewhere to escape the % sign while processing the query for the report.
Here's an example to reproduce this, using some minor modifications the standard 'Active Tickets by Milestone' report.
SELECT p.value AS __color__,
   concat('Milestone % ', milestone) AS __group__,
   id AS ticket, summary, component, version as _version, t.type AS _type, 
   owner, status, j.value as 'planned end date', k.value as 'hours left', 
   time AS _created,
   changetime AS _changetime, description AS _description,
   reporter AS _reporter
  FROM ticket t
  LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
  LEFT JOIN ticket_custom k on t.id = k.ticket and k.name = 'hours_left'
  LEFT JOIN ticket_custom j on t.id = j.ticket and j.name = 'planned_end_date'
  WHERE status <> 'closed' 
  and milestone = '$MILESTONE'
  ORDER BY (milestone IS NULL),milestone, p.value, t.type, time
Then run this report with ?MILESTONE=<some milestone in your system> and notice that the header will now contain two '%' charecters. Removing the $MILESTONE from the query will display the '%' correctly.
I looked through report.py quickly, but I'm not too familiar with it and didn't see anything glaring. Currently running r6121
Attachments (0)
Change History (4)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
| Keywords: | verify added | 
|---|---|
| Milestone: | → 0.11.1 | 
| Severity: | minor → normal | 
comment:3 by , 17 years ago
I assume you are running Trac on MySQL, judging from the concat(). I cannot reproduce this with SQLite. Could you please test that the problem still appears using the latest 0.11-stable? If it does, then it is most likely MySQL-specific.
Please also set the log level to debug, and check the SQL query that is sent to the DB (the log entry starts with "DEBUG: Query SQL:").
comment:4 by , 16 years ago
| Milestone: | next-minor-0.12.x | 
|---|---|
| Resolution: | → worksforme | 
| Status: | new → closed | 
No reply for 18 months, closing.



  
Just noticed I left some custom fields in the SQL.. it should look like this:
SELECT p.value AS __color__, concat('Milestone % ', milestone) AS __group__, id AS ticket, summary, component, version as _version, t.type AS _type, owner, status, time AS _created, changetime AS _changetime, description AS _description, reporter AS _reporter FROM ticket t LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority' WHERE status <> 'closed' and milestone = '$MILESTONE' ORDER BY (milestone IS NULL),milestone, p.value, t.type, time