Modify

Opened 14 years ago

Closed 14 years ago

#6378 closed defect (duplicate)

[patch] Cannot view tickets with MasterTickets plugin installed when using postgres

Reported by: erne.castro@… Owned by: Noah Kantrowitz
Priority: normal Component: MasterTicketsPlugin
Severity: critical Keywords: Postgres
Cc: theyranos@… Trac Release: 0.11

Description

I get this traceback when trying to view a ticket with MasterTicket plugin installed using postgres 8.4 as db backend.

Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11-py2.6.egg/trac/web/api.py", line 339, in send_error
    'text/html')
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11-py2.6.egg/trac/web/chrome.py", line 699, in render_template
    stream |= self._filter_stream(req, method, filename, stream, data)
  File "build/bdist.linux-x86_64/egg/genshi/core.py", line 128, in __or__
    return Stream(_ensure(function(self)), serializer=self.serializer)
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11-py2.6.egg/trac/web/chrome.py", line 802, in inner
    data)
  File "build/bdist.linux-x86_64/egg/ticketguidelines/web_ui.py", line 190, in filter_stream
    stream = stream | Transformer('//form[@id="propertyform"]/h3[1]').after(_get_wiki_html(self.env, data, False))
  File "build/bdist.linux-x86_64/egg/ticketguidelines/web_ui.py", line 66, in _get_wiki_html
    page = WikiPage(env, wiki_page)
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11-py2.6.egg/trac/wiki/model.py", line 43, in __init__
    self._fetch(name, version, db)
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11-py2.6.egg/trac/wiki/model.py", line 64, in _fetch
    (name,))
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11-py2.6.egg/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.11-py2.6.egg/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
InternalError: current transaction is aborted, commands ignored until end of transaction block

I trace the error and it is a implict cast that postgres does not allow in this lines:

        cursor = db.cursor()

        cursor.execute('SELECT dest FROM mastertickets WHERE source=%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,))
        self.blocked_by = set([num for num, in cursor])

I fix it with this patch:

  • mastertickets/model.py

     
    1919        db = db or self.env.get_db_cnx()
    2020        cursor = db.cursor()
    2121
    22         cursor.execute('SELECT dest FROM mastertickets WHERE source=%s ORDER BY dest', (self.tkt.id,))
     22        cursor.execute("SELECT dest FROM mastertickets WHERE source='%s' ORDER BY dest", (self.tkt.id,))
    2323        self.blocking = set([num for num, in cursor])
    2424        self._old_blocking = copy.copy(self.blocking)
    2525
    26         cursor.execute('SELECT source FROM mastertickets WHERE dest=%s ORDER BY source', (self.tkt.id,))
     26        cursor.execute("SELECT source FROM mastertickets WHERE dest='%s' ORDER BY source", (self.tkt.id,))
    2727        self.blocked_by = set([num for num, in cursor])
    2828        self._old_blocked_by = copy.copy(self.blocked_by)

Attachments (0)

Change History (3)

comment:1 Changed 14 years ago by anonymous

Summary: Cannot view tickets with MasterTickets plugin installed when using postgres[patch] Cannot view tickets with MasterTickets plugin installed when using postgres

Here's a (potentially) better patch for this ticket, which sets the types in the database correctly in the first place when you run trac-admin . upgrade

===================================================================
--- 0.11/mastertickets/db_default.py    (revision 7381)
+++ 0.11/mastertickets/db_default.py    (working copy)
@@ -7,7 +7,7 @@
 version = 1
 tables = [
     Table('mastertickets', key=('source','dest'))[
-        Column('source'),
-        Column('dest'),
+        Column('source', type='integer'),
+        Column('dest', type='integer'),
     ],
-]
\ No newline at end of file
+]

comment:2 Changed 14 years ago by theyranos@…

Cc: theyranos@… added; anonymous removed

comment:3 Changed 14 years ago by anonymous

Resolution: duplicate
Status: newclosed

This is a duplicate of #2658

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Noah Kantrowitz.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.