Opened 16 years ago
Closed 11 years ago
#4277 closed defect (fixed)
[Patch] Support for MySQL
Reported by: | Owned by: | Steffen Hoffmann | |
---|---|---|---|
Priority: | normal | Component: | TagsPlugin |
Severity: | critical | Keywords: | SQL specific syntax |
Cc: | Trac Release: | 0.11 |
Description
sqlite syntax and mysql syntax are different, causing ticket.py to fail its query silently. in sqlite:
SELECT "aaa"||"bbb"; => "aaabbb"
in MySQL
SELECT "aaa"||"bbb"; => 0
this impacts the line that in ticket.py which is trying to concatenate the COALESCE'd fields.
changing it to the following allows use of your MySQL-backed trac to work with tags:
sql = "SELECT * FROM (SELECT id, %s, CONCAT(%s) AS fields FROM ticket%s) s" % ( ','.join(self.fields), ", ' ',".join(["COALESCE(%s, '')" % f for f in self.fields]), ignore)
this is a drive-by patch, i'm not a huge python hacker or trac hacker, just upgraded our trac and need tags to work and so hacked this in after sorting through the madness of pythn eggs. it wasn't instantly apparent how to detect the DB provider so i didn't know how to support both sqlite and mysql here.
Attachments (0)
Change History (5)
comment:1 Changed 14 years ago by
Summary: | ticet tags fail silently on MySQL without this patch → [Patch] Support for MySQL |
---|
comment:2 Changed 14 years ago by
comment:3 Changed 13 years ago by
Keywords: | SQL specific syntax added |
---|---|
Owner: | changed from Alec Thomas to Steffen Hoffmann |
Status: | new → assigned |
Well, the proper way to do this is to once more rely on Trac core.
Existing ConnectionWrapper
methods take care of SQL syntax differences between available backends and abstract them away nicely.
comment:5 Changed 13 years ago by
(In [10775]) TagsPlugin: Replace db-specific SQL with Trac ConnectionWrapper
methods, refs #4277.
While the string concatenation has been the major concern, it couldn't hurt to
replace other parts as well with generic methods from trac.db.*_backend.py
.
I've added some more tiny code changes that shouldn't have any impact on code correctness and performance - just code cleanup and personal coding style.
Seems related #3359.