Opened 10 years ago

Last modified 10 years ago

#23834 closed Bug

ArrayField default is an empty string and not None — at Version 2

Reported by: ddaan Owned by:
Component: contrib.postgres Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by ddaan)

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)

Change History (2)

comment:1 by ddaan, 10 years ago

Version: 1.7master

comment:2 by ddaan, 10 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top