Modify

Opened 3 years ago

Closed 8 days ago

Last modified 8 days ago

#11253 closed defect (fixed)

[patch] model.py/save(): INSERT INTO ticket_custom actually never called

Reported by: lostpoint Owned by: rjollos
Priority: normal Component: MasterTicketsPlugin
Severity: normal Keywords:
Cc: Trac Release:

Description (last modified by rjollos)

from model.py:

cursor.execute('UPDATE ticket_custom SET value=%s WHERE ticket=%s AND name=%s',
                                   (new_value, n, field))
# refresh the changetime to prevent concurrent edits
                    cursor.execute('UPDATE ticket SET changetime=%s WHERE id=%s', (when_ts, n))

if not cursor.rowcount:
    cursor.execute('INSERT INTO ticket_custom (ticket, name, value) VALUES (%s, %s, %s)',
                                       (n, field, new_value))

Since there is UPDATE ticket" between "UPDATE ticket_custom and if not cursor.rowcount, INSERT INTO ticket_custom is actually never called, because UPDATE ticket is always OK, no matter if UPDATE ticket_custom completed successfully or there is no such record.

Got this issue on a legacy database where tickets do not have corresponding ticket_custom values for blockedby and blocked.

I did a patch for this issue, you just have to move UPDATE ticket below if not cursor.rowcount - INSERT INTO ticket custom block.

Attachments (1)

ticket_custom.patch (1.0 KB) - added by lostpoint 3 years ago.

Download all attachments as: .zip

Change History (5)

Changed 3 years ago by lostpoint

comment:1 Changed 3 years ago by rjollos

  • Description modified (diff)
  • Status changed from new to accepted

comment:2 Changed 3 years ago by rjollos

  • Status changed from accepted to assigned

comment:3 Changed 8 days ago by rjollos

  • Resolution set to fixed
  • Status changed from assigned to closed

In 16039:

4.0.0dev: Default old_value to None, so that it maps to NULL

Fixes #11253.

comment:4 Changed 8 days ago by rjollos

I think this was fixed in r16037, however I introduced a regression in that changeset that was fixed in r16039.

Add Comment

Modify Ticket

Action
as closed The owner will remain rjollos.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.