Edgewall Software
Modify

Ticket #4447 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years 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:
Release Notes:
API Changes:

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 (867 bytes) - added by thatch 5 years ago.

Download all attachments as: .zip

Change History

comment:1 Changed 5 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?

comment:2 Changed 5 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 5 years ago by thatch

comment:3 Changed 5 years 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, ).

comment:4 Changed 5 years ago by cboos

  • Owner changed from jonas to thatch

I believe that change is correct, please commit.

comment:5 Changed 5 years ago by anonymous

  • Milestone changed from 0.11.1 to 0.11

comment:6 Changed 4 years 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.

comment:7 Changed 4 years 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?

comment:8 Changed 4 years ago by cboos

Yes, just go ahead.

comment:9 Changed 4 years ago by thatch

  • Keywords review removed

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

comment:10 Changed 4 years ago by osimons

  • Milestone changed from 0.11.1 to 0.11
  • Resolution set to fixed
  • Status changed from new to closed

OK. Applied as [6330].

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from thatch. Next status will be 'closed'
Author


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

 
Note: See TracTickets for help on using tickets.