#35449: SplitArrayField doesn't validate properly with remove_trailing_nulls=True ----------------------------------+------------------------------------ Reporter: Matthijs | Owner: (none) Type: Bug | Status: new Component: contrib.postgres | Version: 4.2 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------------+------------------------------------ Changes (by Sarah Boyce):
* stage: Unreviewed => Accepted * summary: SplitArrayField doesn't validate properly (django.contrib.postgres.forms) => SplitArrayField doesn't validate properly with remove_trailing_nulls=True Comment: Thank you! Was able to replicate on main Here is a test if someone needs. {{{#!diff diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py index 386a0afa3a..d45fc1d153 100644 --- a/tests/postgres_tests/test_array.py +++ b/tests/postgres_tests/test_array.py @@ -1339,6 +1339,22 @@ class TestSplitFormField(PostgreSQLSimpleTestCase): ], ) + def test_invalid_char_length_with_remove_trailing_nulls(self): + field = SplitArrayField( + forms.CharField(max_length=2), + size=3, + remove_trailing_nulls=True, + ) + with self.assertRaises(exceptions.ValidationError) as cm: + field.clean(["abc", "", ""]) + self.assertEqual( + cm.exception.messages, + [ + "Item 1 in the array did not validate: Ensure this value has at most 2 " + "characters (it has 3).", + ], + ) + def test_splitarraywidget_value_omitted_from_data(self): }}} -- Ticket URL: <https://code.djangoproject.com/ticket/35449#comment:1> 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 django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018f7677d6b3-e3e10fd2-b436-4014-9e48-709c220a4c20-000000%40eu-central-1.amazonses.com.