Modify ↓
#10207 closed defect (duplicate)
Cannot update a ticket while changing child ticket to parent ticket (and vice versa) with a 'comment'.
Reported by: | anonymous | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Component: | MasterTicketsPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.12 |
Description (last modified by )
While changing child ticket to parent ticket in a ticket ,If we give some comment and submit both then there is no update in ticket and There is Integrity Error
IntegrityError: columns ticket, time, field are not unique File "C:/SDWorkbenchServer/python/lib/site-packages/trac-0.12.2-py2.7.egg/trac/web/main.py", line 511, in _dispatch_request dispatcher.dispatch(req) File "C:/SDWorkbenchServer/python/lib/site-packages/trac-0.12.2-py2.7.egg/trac/web/main.py", line 237, in dispatch resp = chosen_handler.process_request(req) File "C:/SDWorkbenchServer/python/lib/site-packages/trac-0.12.2-py2.7.egg/trac/ticket/web_ui.py", line 169, in process_request return self._process_ticket_request(req) File "C:/SDWorkbenchServer/python/lib/site-packages/trac-0.12.2-py2.7.egg/trac/ticket/web_ui.py", line 541, in _process_ticket_request self._do_save(req, ticket, action) File "C:/SDWorkbenchServer/python/lib/site-packages/trac-0.12.2-py2.7.egg/trac/ticket/web_ui.py", line 1238, in _do_save cnum=internal_cnum): File "C:/SDWorkbenchServer/python/lib/site-packages/trac-0.12.2-py2.7.egg/trac/ticket/model.py", line 360, in save_changes listener.ticket_changed(self, comment, author, old_values) File "C:/SDWorkbenchServer/python/lib/site-packages/tracmastertickets-3.0.2-py2.7.egg/mastertickets/api.py", line 120, in ticket_changed links.save(author, comment, tkt.time_changed, db) File "C:/SDWorkbenchServer/python/lib/site-packages/tracmastertickets-3.0.2-py2.7.egg/mastertickets/model.py", line 83, in save (n, when_ts, author, 'comment', '', '(In #%s) %s'%(self.tkt.id, comment))) File "C:/SDWorkbenchServer/python/lib/site-packages/trac-0.12.2-py2.7.egg/trac/db/util.py", line 65, in execute return self.cursor.execute(sql_escape_percent(sql), args) File "C:/SDWorkbenchServer/python/lib/site-packages/trac-0.12.2-py2.7.egg/trac/db/sqlite_backend.py", line 78, in execute result = PyFormatCursor.execute(self, *args) File "C:/SDWorkbenchServer/python/lib/site-packages/trac-0.12.2-py2.7.egg/trac/db/sqlite_backend.py", line 56, in execute args or []) File "C:/SDWorkbenchServer/python/lib/site-packages/trac-0.12.2-py2.7.egg/trac/db/sqlite_backend.py", line 48, in _rollback_on_error return function(self, *args, **kwargs)
Attachments (1)
Change History (7)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Description: | modified (diff) |
---|
comment:3 Changed 12 years ago by
Unified diff is the preferred format for a patch. If I diff against the latest revision of model.py
, I get:
-
model.py
old new 1 import copy 1 # Created by Noah Kantrowitz on 2007-07-04. 2 # Copyright (c) 2007 Noah Kantrowitz. All rights reserved. 3 import copy 2 4 from datetime import datetime 3 5 4 6 from trac.ticket.model import Ticket … … 7 9 8 10 class TicketLinks(object): 9 11 """A model for the ticket links used MasterTickets.""" 10 12 11 13 def __init__(self, env, tkt, db=None): 12 14 self.env = env 13 15 if not isinstance(tkt, Ticket): … … 46 48 (new_blocked_by, self._old_blocked_by, 'blocking', ('dest', 'source')), 47 49 ] 48 50 49 comment_enable_flag = True50 51 for new_ids, old_ids, field, sourcedest in to_check: 51 52 for n in new_ids | old_ids: 52 53 update_field = None … … 70 71 cursor.execute('INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)', 71 72 (n, when_ts, author, field, old_value, new_value)) 72 73 73 if comment and comment_enable_flag == True: # comment field shound modify once even for multiple changes74 if comment: 74 75 cursor.execute('INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)', 75 76 (n, when_ts, author, 'comment', '', '(In #%s) %s'%(self.tkt.id, comment))) 76 comment_enable_flag = False77 77 78 78 79 cursor.execute('UPDATE ticket_custom SET value=%s WHERE ticket=%s AND name=%s', 79 80 (new_value, n, field)) … … 84 85 if not cursor.rowcount: 85 86 cursor.execute('INSERT INTO ticket_custom (ticket, name, value) VALUES (%s, %s, %s)', 86 87 (n, field, new_value)) 87 88 89 # cursor.execute('DELETE FROM mastertickets WHERE source=%s OR dest=%s', (self.tkt.id, self.tkt.id)) 90 # data = [] 91 # for tkt in self.blocking: 92 # if isinstance(tkt, Ticket): 93 # tkt = tkt.id 94 # data.append((self.tkt.id, tkt)) 95 # for tkt in self.blocked_by: 96 # if isisntance(tkt, Ticket): 97 # tkt = tkt.id 98 # data.append((tkt, self.tkt.id)) 99 # 100 # cursor.executemany('INSERT INTO mastertickets (source, dest) VALUES (%s, %s)', data) 88 101 89 102 if handle_commit: 90 103 db.commit() … … 105 118 (self.tkt.id, l(getattr(self, 'blocking', [])), l(getattr(self, 'blocked_by', []))) 106 119 107 120 @staticmethod 108 def walk_tickets(env, tkt_ids ):121 def walk_tickets(env, tkt_ids, full=False): 109 122 """Return an iterable of all links reachable directly above or below those ones.""" 110 def visit(tkt, memo, next_fn ):123 def visit(tkt, memo, next_fn, full=False): 111 124 if tkt in memo: 112 125 return False 113 126 … … 120 133 memo1 = {} 121 134 memo2 = {} 122 135 for id in tkt_ids: 123 visit(id, memo1, lambda links: links.blocking) 124 visit(id, memo2, lambda links: links.blocked_by) 136 if full: 137 visit(id, memo1, lambda links: links.blocking|links.blocked_by) 138 else: 139 visit(id, memo1, lambda links: links.blocking) 140 visit(id, memo2, lambda links: links.blocked_by) 125 141 memo1.update(memo2) 126 142 return memo1.itervalues()
comment:4 Changed 12 years ago by
Owner: | changed from Noah Kantrowitz to Ryan J Ollos |
---|---|
Status: | new → assigned |
comment:5 Changed 12 years ago by
Summary: | Cannot update a ticket while changing child ticket to patent ticket(and vice versa) with a 'comment'. → Cannot update a ticket while changing child ticket to parent ticket (and vice versa) with a 'comment'. |
---|
comment:6 Changed 12 years ago by
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
Note: See
TracTickets for help on using
tickets.
When we updating parent/child ticket with comment , the logic (for loop) was iterating 2 times to modify "parent field" and "child field" each in model.py . Each time while modifying if comment is given in field , it was updating that also. In first iteration the comment field was modified so in second iteration while changing it was throwing error. By making comment field to change only in one time, we can prevent the error. check out modified script(model.py) as attachment.