#26283: SplitArrayField failed to validate because remove_trailing_nulls doesn't
work properly
----------------------------------+--------------------------------------
Reporter: mochawich | Owner:
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Comment (by mochawich):
The test you proposed will not fail because you checked for the wrong
value
{{{
self.assertEqual(form.cleaned_data, {'array': ['', '']})
}}}
You should have checked for an empty array instead as in
{{{
self.assertEqual(form.cleaned_data, {'array': []})
}}}
Since all values are considered empty characters `remove_trailing_nulls`
should result in an empty array. Not in an array that has empty values.
Such an array doesn't pass the later check of the form here
line 1188 db.models.base.py
{{{
# Skip validation for empty fields with blank=True. The
developer
# is responsible for making sure they have a valid value.
raw_value = getattr(self, f.attname)
if f.blank and raw_value in f.empty_values:
continue
}}}
In this case the `raw_value` is ['', ''] while it should have been
trimmed.
--
Ticket URL: <https://code.djangoproject.com/ticket/26283#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.efab84759307f44b2501aef72dcd3b8b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.