Author: rjollos
Date: Sun Dec 29 07:57:42 2013
New Revision: 1554000

URL: http://svn.apache.org/r1554000
Log:
0.8dev: Do not populate tickets with negative IDs. Refs #668.

Patch by Olemis.

Modified:
    bloodhound/trunk/trac/trac/ticket/model.py

Modified: bloodhound/trunk/trac/trac/ticket/model.py
URL: 
http://svn.apache.org/viewvc/bloodhound/trunk/trac/trac/ticket/model.py?rev=1554000&r1=1553999&r2=1554000&view=diff
==============================================================================
--- bloodhound/trunk/trac/trac/ticket/model.py (original)
+++ bloodhound/trunk/trac/trac/ticket/model.py Sun Dec 29 07:57:42 2013
@@ -242,11 +242,17 @@ class Ticket(object):
             if getattr(self.env, '_multiproduct_schema_enabled', False):
                 tkt_id = db.get_last_id(cursor, 'ticket', 'uid')
                 rows = db("""SELECT id FROM ticket WHERE uid=%s""", (tkt_id,))
-                tkt_id = rows[0][0] if rows else -1
+                if len(rows) != 1:
+                    # One row SHOULD always be retrieved, but if it does not
+                    # then insertion MUST fail since the cause may be a bug in 
+                    # BH SQL translator executing previous INSERT without
+                    # product prefix properly setup.
+                    # By raising the error the transaction should be rolled 
back
+                    raise AssertionError("No ticket id for uid " + str(tkt_id))
+                tkt_id = rows[0][0]
             else:
                 tkt_id = db.get_last_id(cursor, 'ticket')
 
-
             # Insert custom fields
             if custom_fields:
                 db.executemany(


Reply via email to