trac.plugins.ticketref / ticketref / model.py

Diff from to

ticketref/model.py

 SELECT_TICKETREF = "SELECT value FROM ticket_custom "\
                    "WHERE ticket=%%s AND name='%s'" % TICKETREF
 INSERT_TICKETREF = "INSERT INTO ticket_custom (ticket, name, value) "\
-                   "VALUES (%%s, '%s', '%%s')" % TICKETREF
-UPDATE_TICKETREF = "UPDATE ticket_custom SET value='%%s' "\
+                   "VALUES (%%s, '%s', %%s)" % TICKETREF
+UPDATE_TICKETREF = "UPDATE ticket_custom SET value=%%s "\
                    "WHERE ticket=%%s AND name='%s'" % TICKETREF
 DELETE_TICKETREF = "DELETE FROM ticket_custom "\
                    "WHERE ticket=%%s AND name='%s'" % TICKETREF
 
 INSERT_TICKETCHG = "INSERT INTO ticket_change "\
                    "(ticket, time, author, field, oldvalue, newvalue) "\
-                   "VALUES (%%s, %%s, '%%s', '%s', '%%s', '%%s')" % TICKETREF
+                   "VALUES (%%s, %%s, %%s, '%s', %%s, %%s)" % TICKETREF
 
 
 class TicketLinks(object):
     def add_reference(self, refs):
         c = self.cursor
         for ref_id in refs:
-            c.execute(SELECT_TICKETREF % self.ticket.id)
+            c.execute(SELECT_TICKETREF, (self.ticket.id,))
             row = c.fetchone()
             if row:
                 target_refs = cnv_text2list(row[0])
                 if not ref_id in target_refs:
                     target_refs.add(ref_id)
                     new_text = cnv_list2text(target_refs)
-                    c.execute(UPDATE_TICKETREF % (new_text, self.ticket.id))
+                    c.execute(UPDATE_TICKETREF, (new_text, self.ticket.id))
                     self.ticket[TICKETREF] = cnv_sorted_refs(
                                         self.ticket[TICKETREF], set([ref_id]))
             else:
-                c.execute(INSERT_TICKETREF % (self.ticket.id, ref_id))
+                c.execute(INSERT_TICKETREF, (self.ticket.id, ref_id))
                 self.ticket[TICKETREF] = u"%s" % ref_id
 
     def remove_cross_reference(self, refs, author):
         c = self.cursor
         for ref_id in refs:
-            c.execute(SELECT_TICKETREF % ref_id)
+            c.execute(SELECT_TICKETREF, (ref_id,))
             row = (c.fetchone() or ("",))[0]
             target_refs = cnv_text2list(row)
             target_refs.remove(self.ticket.id)
             if target_refs:
                 new_text = cnv_list2text(target_refs)
-                c.execute(UPDATE_TICKETREF % (new_text, ref_id))
+                c.execute(UPDATE_TICKETREF, (new_text, ref_id))
             else:
                 new_text = ""
-                c.execute(DELETE_TICKETREF % ref_id)
-            c.execute(INSERT_TICKETCHG % (
+                c.execute(DELETE_TICKETREF, (ref_id,))
+            c.execute(INSERT_TICKETCHG, (
                 ref_id, self.time_stamp, author, row.strip(), new_text))
-            c.execute(UPDATE_TICKET % (self.time_stamp, ref_id))
+            c.execute(UPDATE_TICKET, (self.time_stamp, ref_id))
 
     def add_cross_reference(self, refs, author):
         c = self.cursor
         for ref_id in refs:
-            c.execute(SELECT_TICKETREF % ref_id)
+            c.execute(SELECT_TICKETREF, (ref_id,))
             row = c.fetchone()
             if row:
                 target_refs = cnv_text2list(row[0])
                 if not self.ticket.id in target_refs:
                     target_refs.add(self.ticket.id)
                     new_text = cnv_list2text(target_refs)
-                    c.execute(UPDATE_TICKETREF % (new_text, ref_id))
-                    c.execute(INSERT_TICKETCHG % (ref_id, self.time_stamp,
+                    c.execute(UPDATE_TICKETREF, (new_text, ref_id))
+                    c.execute(INSERT_TICKETCHG, (ref_id, self.time_stamp,
                                 author, row[0].strip(), new_text))
-                    c.execute(UPDATE_TICKET % (self.time_stamp, ref_id))
+                    c.execute(UPDATE_TICKET, (self.time_stamp, ref_id))
             else:
-                c.execute(INSERT_TICKETREF % (ref_id, self.ticket.id))
-                c.execute(INSERT_TICKETCHG % (
+                c.execute(INSERT_TICKETREF, (ref_id, self.ticket.id))
+                c.execute(INSERT_TICKETCHG, (
                     ref_id, self.time_stamp, author, "", self.ticket.id))
-                c.execute(UPDATE_TICKET % (self.time_stamp, ref_id))
+                c.execute(UPDATE_TICKET, (self.time_stamp, ref_id))
 
     def create(self):
         refs = cnv_text2list(self.ticket[TICKETREF])
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.