Edgewall Software
Modify

Opened 18 years ago

Closed 17 years ago

Last modified 11 years ago

#4447 closed defect (fixed)

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

Reported by: Tim Hatch Owned by: Tim Hatch
Priority: normal Milestone: 0.11
Component: ticket system Version: devel
Severity: normal Keywords: custom fields
Cc: Ryan J Ollos Branch:
Release Notes:
API Changes:
Internal 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 (1)

t4447-dont-save-empty-field-changes.diff (867 bytes ) - added by Tim Hatch 18 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by Christian Boos, 18 years ago

Keywords: custom fields added
Milestone: 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 by Tim Hatch, 18 years ago

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 ''?

comment:3 by Tim Hatch, 18 years ago

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 by Christian Boos, 17 years ago

Owner: changed from Jonas Borgström to Tim Hatch

I believe that change is correct, please commit.

comment:5 by anonymous, 17 years ago

Milestone: 0.11.10.11

comment:6 by ThurnerRupert, 17 years ago

Milestone: 0.110.11.1

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

comment:7 by osimons, 17 years ago

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 by Christian Boos, 17 years ago

Yes, just go ahead.

comment:9 by Tim Hatch, 17 years ago

Keywords: review removed

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

comment:10 by osimons, 17 years ago

Milestone: 0.11.10.11
Resolution: fixed
Status: newclosed

OK. Applied as [6330].

comment:11 by Ryan J Ollos, 11 years ago

Cc: Ryan J Ollos added

I encountered a random functional test case failure because delete was one of the words in the random content. The functional test was added in [6784].

======================================================================
FAIL: runTest (trac.ticket.tests.functional.RegressionTestTicket4447)
Test for regression of http://trac.edgewall.org/ticket/4447
----------------------------------------------------------------------
Traceback (most recent call last):
  File "trac/ticket/tests/functional.py", line 1349, in runTest
    tc.notfind('deleted')
  File "trac/tests/functional/better_twill.py", line 226, in better_notfind
    raise twill.errors.TwillAssertionError(*args)
TwillAssertionError: ("match to 'deleted'", '/home/user/Workspace/t5658/teo-rjollos.git/testenv/trac/log/RegressionTestTicket4447.html')

----------------------------------------------------------------------
Ran 1578 tests in 272.221s

FAILED (failures=1)

I've reproduced the defect with this change:

  • trac/ticket/web_ui.py

    diff --git a/trac/ticket/web_ui.py b/trac/ticket/web_ui.py
    index e3f1ada..52cbee3 100644
    a b class TicketModule(Component):  
    18131813                comment_history.setdefault(rev, {}).update({'comment': old})
    18141814                comment_history.setdefault(rev + 1, {}).update(
    18151815                        {'author': author, 'date': from_utimestamp(long(new))})
    1816             elif (old or new) and old != new:
     1816            else:
    18171817                current['fields'][field] = {
    18181818                    'old': old, 'new': new,
    18191819                    'label': field_labels.get(field, field)}

A fix to avoid a random failure of the regression test was applied to 1.0-stable in [12155] and merged to trunk in [12156].

comment:12 by Jun Omae, 11 years ago

I got another random failure. But, I cannot reproduce the issue with reverting [6330]. It seems no need for the tc.notfind('set to').

======================================================================
FAIL: runTest (trac.ticket.tests.functional.RegressionTestTicket4447)
Test for regression of http://trac.edgewall.org/ticket/4447
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/run/shm/4cc6ddc6443b8a6f6d79ebceac6e21dfcbc4b726/py27-mysql/trac/ticket/tests/functional.py", line 1558, in runTest
    tc.notfind('set to')
  File "/run/shm/4cc6ddc6443b8a6f6d79ebceac6e21dfcbc4b726/py27-mysql/trac/tests/functional/better_twill.py", line 234, in better_notfind
    raise twill.errors.TwillAssertionError(*args)
TwillAssertionError: ("match to 'set to'", '/run/shm/4cc6ddc6443b8a6f6d79ebceac6e21dfcbc4b726/py27-mysql/testenv/trac/log/RegressionTestTicket4447.html')

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Tim Hatch.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Tim Hatch to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.