Opened 18 years ago
Closed 18 years ago
#5514 closed defect (duplicate)
Dynamic variable $USER gets double-quoted on Trac+MySQL
| Reported by: | xurizaemon | Owned by: | Matthew Good |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | report system | Version: | 0.10.3.1 |
| Severity: | normal | Keywords: | |
| Cc: | xurizaemon@… | Branch: | |
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
The default reports contain references to dynamic variable $USER with queries like (report 6)
SELECT p.value AS __color__,
t.milestone AS __group__,
(CASE status
WHEN 'closed' THEN 'color: #777; background: #ddd; border-color: #ccc;'
ELSE
(CASE owner WHEN '$USER' THEN 'font-weight: bold' END)
END) AS __style__,
id AS ticket, summary, component, status,
resolution,version, t.type AS type, priority, owner,
changetime AS modified,
time AS _time,reporter AS _reporter
FROM ticket t
LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
ORDER BY (milestone IS NULL), milestone DESC, (status = 'closed'),
(CASE status WHEN 'closed' THEN modified ELSE (-1)*p.value END) DESC
This throws the error, Report execution failed: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 'kris', ')' THEN 'font-weight: bold' END)\r\n END) AS style,\r\n id AS tic' at line 6")
By replacing '$USER' with $USER in the report query, the error disappears and the report works fine. It appears that this combination of Trac+Python+MySQL quotes the dynamic variables, leading to errors when the original queries using the extra quote are used.
- Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
- MySQL 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution
- Trac 0.10.3-1
- Ubuntu Feisty
(Apologies if this is a dupe, I did search and didn't find anything matching $USER and MySQL.)



Apologies, this has been fixed already. #4387