#23834: ArrayField default is an empty string and not None
----------------------------------+--------------------------------------
Reporter: ddaan | Owner:
Type: Bug | Status: new
Component: contrib.postgres | Version: master
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
----------------------------------+--------------------------------------
Description changed by ddaan:
Old description:
> Considering this class (from tests.postgres_tests.models):
>
> class NullableIntegerArrayModel(models.Model):
> field = ArrayField(models.IntegerField(), blank=True, null=True)
>
> When I save it directly after initialization it will result in an error
>
> django.db.utils.DataError: array value must start with "{" or dimension
> information
> LINE 1: ...ests_nullableintegerarraymodel" ("field") VALUES ('')
> RETURN...
>
> This test will reproduce the error
>
> def test_default_null(self):
> instance = NullableIntegerArrayModel()
> instance.save()
> loaded = NullableIntegerArrayModel.objects.get(pk=instance.pk)
> self.assertEqual(loaded.field, None)
> self.assertEqual(instance.field, loaded.field)
New description:
Considering this class (from tests.postgres_tests.models):
{{{
class NullableIntegerArrayModel(models.Model):
field = ArrayField(models.IntegerField(), blank=True, null=True)
}}}
When I save it directly after initialization it will result in an error
django.db.utils.DataError: array value must start with "{" or dimension
information
LINE 1: ...ests_nullableintegerarraymodel" ("field") VALUES ('') RETURN...
This test will reproduce the error
{{{
def test_default_null(self):
instance = NullableIntegerArrayModel()
instance.save()
loaded = NullableIntegerArrayModel.objects.get(pk=instance.pk)
self.assertEqual(loaded.field, None)
self.assertEqual(instance.field, loaded.field)
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/23834#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/063.7973debfaf27d6bf8afd5dc36ce567e9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.