Edgewall Software

Ticket #4447 (closed defect: fixed)

Opened 2 years ago

Last modified 12 months ago

Custom ticket field edits from None to '' show as deletion

Reported by: thatch Owned by: thatch
Priority: normal Milestone: 0.11
Component: ticket system Version: devel
Severity: normal Keywords: custom fields
Cc:

Description

I started this on trac-dev but convinced myself that it was a real issue. See that message for steps to reproduce

Just as a followup, templates/ticket_view.html displays field_name deleted when a custom field goes from None to ''. This is caused by a custom field being added after a ticket is created. I don't believe this to be a change (much less a deletion) so propose the following:

  • trac/ticket/web_ui.py

     
    849849                    else: 
    850850                        this_num = old 
    851851                    current['cnum'] = int(this_num) 
    852             else: 
     852            elif old or new: 
    853853                current['fields'][field] = {'old': old, 'new': new} 
    854854        if current: 
    855855            yield current 

The unit tests appear to still pass as expected.


The ticket_change table is storing:

434|1166731555|<my username>|due_date||

And pysqlite2 is giving me the tuple

(434, 1166731555, u'<my username>', u'due_date', None, u'')

Attachments

t4447-dont-save-empty-field-changes.diff (0.8 KB) - added by thatch 21 months ago.

Change History

Changed 2 years ago by cboos

  • keywords custom fields added
  • milestone set to 0.11

The problem is that we can't distinguish between a new custom field not set and a new custom field explicitly set to blank, otherwise I would have said we shouldn't write the custom field in the first place, therefore we would even avoid the problem.

But this could perhaps be an alternative solution. What would happen if we would not save fields with blank values (they'd simply be not there in the ticket_custom ). Wouldn't that work?

Changed 2 years ago by thatch

Not writing None-to-'' on saving tickets works for me. Basically if ticket_custom doesn't have a value already for the relevant field, it wouldn't be added as an entry into ticket_change when the new value is ''?

Changed 21 months ago by thatch

Changed 21 months ago by thatch

  • keywords review added

See attachment:t4447-dont-save-empty-field-changes.diff for an implementation of cboos' suggestion. I think it's doing a string comparison so the only way the change won't get written is if they're both in (None, ).

Changed 18 months ago by cboos

  • owner changed from jonas to thatch

I believe that change is correct, please commit.

Changed 18 months ago by anonymous

  • milestone changed from 0.11.1 to 0.11

Changed 16 months ago by ThurnerRupert

  • milestone changed from 0.11 to 0.11.1

no regression, so leave at 0.11.1 as it seems to block 0.11 unnecessarily.

Changed 12 months ago by osimons

Just ran into this one as well today - tested it and, and the custom field no longer appear as deleted just because it had been created in the timespan between comments. Good.

Anyone committing this, or should I just go ahead? thatch?

Changed 12 months ago by cboos

Yes, just go ahead.

Changed 12 months ago by thatch

  • keywords review removed

It's fine to me, so please go ahead and apply, osimons.

Changed 12 months ago by osimons

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from 0.11.1 to 0.11

OK. Applied as [6330].

Add/Change #4447 (Custom ticket field edits from None to '' show as deletion)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from thatch. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.