#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
849 849 else: 850 850 this_num = old 851 851 current['cnum'] = int(this_num) 852 el se:852 elif old or new: 853 853 current['fields'][field] = {'old': old, 'new': new} 854 854 if current: 855 855 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)
Change History (13)
comment:1 by , 18 years ago
Keywords: | custom fields added |
---|---|
Milestone: | → 0.11 |
comment:2 by , 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 ''
?
by , 18 years ago
Attachment: | t4447-dont-save-empty-field-changes.diff added |
---|
comment:3 by , 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:5 by , 17 years ago
Milestone: | 0.11.1 → 0.11 |
---|
comment:6 by , 17 years ago
Milestone: | 0.11 → 0.11.1 |
---|
no regression, so leave at 0.11.1 as it seems to block 0.11 unnecessarily.
comment:7 by , 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:9 by , 17 years ago
Keywords: | review removed |
---|
It's fine to me, so please go ahead and apply, osimons.
comment:10 by , 17 years ago
Milestone: | 0.11.1 → 0.11 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
OK. Applied as [6330].
comment:11 by , 11 years ago
Cc: | 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): 1813 1813 comment_history.setdefault(rev, {}).update({'comment': old}) 1814 1814 comment_history.setdefault(rev + 1, {}).update( 1815 1815 {'author': author, 'date': from_utimestamp(long(new))}) 1816 el if (old or new) and old != new:1816 else: 1817 1817 current['fields'][field] = { 1818 1818 'old': old, 'new': new, 1819 1819 '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 , 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')
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?