Edgewall Software

Ticket #6319 (new defect)

Opened 13 months ago

Last modified 3 months ago

Literal '%' gets duplicated in report with $VARIABLE replacement

Reported by: ryank@… Owned by: mgood
Priority: normal Milestone: 0.11-retriage
Component: report system Version: devel
Severity: normal Keywords: verify
Cc:

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

Change History

in reply to: ↑ description   Changed 12 months ago by anonymous

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

  Changed 12 months ago by cboos

  • keywords verify added
  • severity changed from minor to normal
  • milestone set to 0.11.1

  Changed 3 months ago by rblank

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:").

Add/Change #6319 (Literal '%' gets duplicated in report with $VARIABLE replacement)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from mgood. Next status will be 'new'
The owner will change from mgood to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.