Opened 12 years ago

Last modified 3 years ago

#10194 new defect

Cannot update a ticket using trac.ticket.model.save_changes with both a 'comment' and a 'when' field. — at Version 6

Reported by: François Granade Owned by: Ryan J Ollos
Priority: normal Component: MasterTicketsPlugin
Severity: normal Keywords:
Cc: Jun Omae, falkb Trac Release: 0.12

Description (last modified by Ryan J Ollos)

This was found in the TicketImportPlugin, see #10188, and took me some time to debug. The following piece of code (given an env environment):

from trac.ticket.web_ui import Ticket 
from datetime import datetime 
from trac.util.datefmt import utc 
ticket = Ticket(env) 
ticket['summary'] = 'The summary' 
ticket.insert() 
ticket['blockedby'] = str(ticket.id) 
ticket.save_changes('someone', comment='Some comments',
                    when=datetime.now(utc)) 

will work if the MasterTicketsPlugin is not installed, but will fail if it is installed, with the following error:

ticket.save_changes('someone', 'Some comments',
                    when=datetime.now(utc))
  File "/Users/francois/ticketimportplugin/0.11/env2.5/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/ticket/model.py", line 353, in save_changes
    listener.ticket_changed(self, comment, author, old_values)
  File "build/bdist.macosx-10.7-x86_64/egg/mastertickets/api.py", line 111, in ticket_changed
    links.save(author, comment, tkt.time_changed, db)
  File "build/bdist.macosx-10.7-x86_64/egg/mastertickets/model.py", line 76, in save
    (n, when_ts, author, 'comment', '', '(In #%s) %s'%(self.tkt.id, comment)))
  File "/Users/francois/ticketimportplugin/0.11/env2.5/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/db/util.py", line 65, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/Users/francois/ticketimportplugin/0.11/env2.5/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/db/sqlite_backend.py", line 79, in execute
    result = PyFormatCursor.execute(self, *args)
  File "/Users/francois/ticketimportplugin/0.11/env2.5/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/db/sqlite_backend.py", line 57, in execute
    args or [])
  File "/Users/francois/ticketimportplugin/0.11/env2.5/lib/python2.5/site-packages/Trac-0.12-py2.5.egg/trac/db/sqlite_backend.py", line 48, in _rollbac\
k_on_error
    return function(self, *args, **kwargs)
IntegrityError: columns ticket, time, field are not unique

See browser:ticketimportplugin/0.11/talm_importer/test.py@11805#L460

Change History (6)

comment:1 Changed 11 years ago by Jun Omae

Cc: Jun Omae added; anonymous removed

comment:2 Changed 11 years ago by falkb

Cc: falkb added

comment:3 Changed 11 years ago by falkb

Cc: Ryan J Ollos added

Any progress or patches I could test?

comment:4 Changed 11 years ago by Ryan J Ollos

Cc: Ryan J Ollos removed
Owner: changed from Noah Kantrowitz to Ryan J Ollos
Status: newassigned

Yeah, I'll be pushing some changes shortly.

comment:5 in reply to:  4 Changed 11 years ago by falkb

Replying to rjollos:

Yeah, I'll be pushing some changes shortly.

Do you know now when "shortly" is?

comment:6 Changed 11 years ago by Ryan J Ollos

Description: modified (diff)
Note: See TracTickets for help on using tickets.