Modify

Opened 6 years ago

Closed 4 months ago

#4277 closed defect (fixed)

[Patch] Support for MySQL

Reported by: nat@… Owned by: hasienda
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 4 years ago by rjollos

  • Summary changed from ticet tags fail silently on MySQL without this patch to [Patch] Support for MySQL

comment:2 Changed 4 years ago by AdrianFritz

Seems related #3359.

comment:3 Changed 3 years ago by hasienda

  • Keywords SQL specific syntax added
  • Owner changed from athomas to hasienda
  • Status changed from new to 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 3 years ago by hasienda

(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.

comment:6 Changed 4 months ago by hasienda

  • Resolution set to fixed
  • Status changed from assigned to closed

In 13815:

TagsPlugin: Completing preparation for v0.7 release.

Availability of that code as stable, tagged release
closes #2429, #3359, #3610, #3624, #3677, #3754, #3864, #3947, #3983, #4078, #4277, #4503, #4799, #5523, #7787, #7857, #8638, #9057, #9058, #9059, #9060, #9061, #9062, #9063, #9149, #9210, #9521, #9630, #9636, #10032, #10416, #10636, #11096, #11147, #11152, #11274, #11302, #11658 and #11659.

Additionally there are some issues and enhancement requests showing progress,
but known to require more work to resolve them satisfactorily, specifically
refs #2804, #4200, #8747 and #9064.

Thanks to all contributors and followers, that enabled and encouraged a good
portion of this development work.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from hasienda. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.