I have gotten mastertickets to work with postgresql 8.3.  The problem is SQL 
like

  "WHERE dest = %s", self.tkt.id()

which for example passes "WHERE dest = 34" which was fine in earlier
pgsql but causes 8.3 to throw a type mismatch error because there is no
= function that takes a strings and a number.

I put the following patch in pkgsrc, and that resolves the issue.  I
suspect this is portable SQL, but I am not quite sure.  I believe I
could also use \'%s\', and I wonder if people prefer that.

--- mastertickets/model.py.orig 2009-08-04 13:50:22.000000000 -0400
+++ mastertickets/model.py
@@ -19,11 +19,11 @@ class TicketLinks(object):
         db = db or self.env.get_db_cnx()
         cursor = db.cursor()
         
-        cursor.execute('SELECT dest FROM mastertickets WHERE source=%s ORDER 
BY dest', (self.tkt.id,))
+        cursor.execute('SELECT dest FROM mastertickets WHERE source=text(%s) 
ORDER BY dest', (self.tkt.id,))
         self.blocking = set([num for num, in cursor])
         self._old_blocking = copy.copy(self.blocking)
         
-        cursor.execute('SELECT source FROM mastertickets WHERE dest=%s ORDER 
BY source', (self.tkt.id,))
+        cursor.execute('SELECT source FROM mastertickets WHERE dest=text(%s) 
ORDER BY source', (self.tkt.id,))
         self.blocked_by = set([num for num, in cursor])
         self._old_blocked_by = copy.copy(self.blocked_by)
         
@@ -54,7 +54,7 @@ class TicketLinks(object):
                     update_field = lambda lst: lst.append(str(self.tkt.id))
                 elif n not in new_ids and n in old_ids:
                     # Old ticket removed
-                    cursor.execute('DELETE FROM mastertickets WHERE %s=%%s AND 
%s=%%s'%sourcedest, (self.tkt.id, n))
+                    cursor.execute('DELETE FROM mastertickets WHERE 
%s=text(%%s) AND %s=text(%%s)'%sourcedest, (self.tkt.id, n))
                     update_field = lambda lst: lst.remove(str(self.tkt.id))
                 
                 if update_field is not None:


I'll revise the patch based on comments, and then I'd like to commit it
to the trac-hacks repository, or have someone else commit it.  What is
the procedure for that (review/approval rules, mechanics)?

Attachment: pgpBehfiBN3Al.pgp
Description: PGP signature

Reply via email to