Index: model.py
===================================================================
--- model.py	(revision 6511)
+++ model.py	(working copy)
@@ -297,7 +297,7 @@
                            "SELECT time,author,'comment',null,description,0 "
                            "FROM attachment WHERE id=%s AND time=%s "
                            "ORDER BY time",
-                           (self.id, when_ts, str(self.id), when_ts, self.id, when_ts))
+                           (self.id, when_ts, str(self.id), when_ts, str(self.id), when_ts))
         else:
             cursor.execute("SELECT time,author,field,oldvalue,newvalue,1 "
                            "FROM ticket_change WHERE ticket=%s "
@@ -307,7 +307,7 @@
                            "UNION "
                            "SELECT time,author,'comment',null,description,0 "
                            "FROM attachment WHERE id=%s "
-                           "ORDER BY time", (self.id,  str(self.id), self.id))
+                           "ORDER BY time", (self.id,  str(self.id), str(self.id)))
         log = []
         for t, author, field, oldvalue, newvalue, permanent in cursor:
             log.append((datetime.fromtimestamp(int(t), utc), author, field,

