[Django] #22962: Default of [] for postgres array field results in migration application failure.

152 views
Skip to first unread message

Django

unread,
Jul 5, 2014, 2:31:29 AM7/5/14
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
----------------------------------+--------------------
Reporter: schinckel | Owner:
Type: Uncategorized | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------
Creating an ArrayField with a default of [] results in an error when
attempting to run the migration:

django.db.utils.DataError: missing dimension value


It seems that the literal [] is being sent through to the database, rather
than the postgres-speak for an empty array: '{}'

It's the same issue as seen elsewhere on the internet when dealing with
postgres arrays:

https://github.com/ecometrica/django-dbarray/issues/2

--
Ticket URL: <https://code.djangoproject.com/ticket/22962>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 5, 2014, 2:32:40 AM7/5/14
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
----------------------------------+--------------------------------------

Reporter: schinckel | Owner:
Type: Uncategorized | 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
----------------------------------+--------------------------------------
Changes (by schinckel):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Oh, it was an undimensioned array: not sure if that's important.

--
Ticket URL: <https://code.djangoproject.com/ticket/22962#comment:1>

Django

unread,
Jul 5, 2014, 2:37:42 AM7/5/14
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
----------------------------------+--------------------------------------

Reporter: schinckel | Owner:
Type: Uncategorized | 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
----------------------------------+--------------------------------------

Comment (by schinckel):

In ArrayField.get_prep_value(self,value), adding:

if value == '[]':
value = '{}'

makes it work as expected.

--
Ticket URL: <https://code.djangoproject.com/ticket/22962#comment:2>

Django

unread,
Jul 11, 2014, 1:23:10 PM7/11/14
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
----------------------------------+------------------------------------
Reporter: schinckel | Owner:
Type: Bug | Status: new
Component: contrib.postgres | Version: master
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 timo):

* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/22962#comment:3>

Django

unread,
Jul 15, 2014, 7:49:19 AM7/15/14
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
----------------------------------+------------------------------------
Reporter: schinckel | Owner:
Type: Bug | Status: new
Component: contrib.postgres | Version: master

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
----------------------------------+------------------------------------

Comment (by mjtamlyn):

PR: https://github.com/django/django/pull/2925

Not sure why I am getting a string from the migration runner, seems a
little strange. Nonetheless it works now.

--
Ticket URL: <https://code.djangoproject.com/ticket/22962#comment:4>

Django

unread,
Jul 15, 2014, 7:49:33 AM7/15/14
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
----------------------------------+------------------------------------
Reporter: schinckel | Owner:
Type: Bug | Status: new
Component: contrib.postgres | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by mjtamlyn):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/22962#comment:5>

Django

unread,
Jul 29, 2014, 5:37:48 AM7/29/14
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
-------------------------------------+-------------------------------------
Reporter: schinckel | Owner: Marc
Type: Bug | Tamlyn <marc.tamlyn@…>
Component: contrib.postgres | Status: closed
Severity: Normal | Version: master
Keywords: | Resolution: fixed
Has patch: 1 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Marc Tamlyn <marc.tamlyn@…>):

* status: new => closed
* owner: => Marc Tamlyn <marc.tamlyn@…>
* resolution: => fixed


Comment:

In [changeset:"ef9f109013adc6e140c1a71d874aa88e893657b7"]:
{{{
#!CommitTicketReference repository=""
revision="ef9f109013adc6e140c1a71d874aa88e893657b7"
Fixed #22962 -- Default values for ArrayField with migrations.

Fields normally try to force the default value to a string. As
translatable strings are not valid default values for ArrayField, we can
remove this behaviour which was causing issues with some migrations.

Thanks to @schinckel for the report.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22962#comment:6>

Django

unread,
Feb 13, 2015, 8:30:28 AM2/13/15
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
-------------------------------------+-------------------------------------
Reporter: schinckel | Owner: Marc
| Tamlyn <marc.tamlyn@…>
Type: Bug | Status: closed
Component: contrib.postgres | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Markus Holtermann <info@…>):

In [changeset:"b06935a486e633e9732bce2bc5f796eb437b2531"]:
{{{
#!CommitTicketReference repository=""
revision="b06935a486e633e9732bce2bc5f796eb437b2531"
Refs #22962 -- Made test case use non-conflicting table names
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22962#comment:7>

Django

unread,
Feb 13, 2015, 9:22:45 AM2/13/15
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
-------------------------------------+-------------------------------------
Reporter: schinckel | Owner: Marc
| Tamlyn <marc.tamlyn@…>
Type: Bug | Status: closed
Component: contrib.postgres | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Markus Holtermann <info@…>):

In [changeset:"45d93baf518218c39b70fbc1eb35e9b53f66cf98"]:
{{{
#!CommitTicketReference repository=""
revision="45d93baf518218c39b70fbc1eb35e9b53f66cf98"
[1.8.x] Refs #22962 -- Made test case use non-conflicting table names

Backport of b06935a486e633e9732bce2bc5f796eb437b2531 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22962#comment:8>

Django

unread,
Mar 29, 2017, 4:53:42 AM3/29/17
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Marc
| Tamlyn <marc.tamlyn@…>
Type: Bug | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Doug Whiteley):

* status: closed => new
* resolution: fixed =>


Comment:

This is happening again.


{{{
django.db.utils.DataError: malformed array literal: ""
DETAIL: Array value must start with "{" or dimension information.
}}}

Checked on 1.10 and 1.11rc1.

--
Ticket URL: <https://code.djangoproject.com/ticket/22962#comment:9>

Django

unread,
Mar 29, 2017, 5:21:46 AM3/29/17
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Marc
| Tamlyn <marc.tamlyn@…>
Type: Bug | Status: new
Component: contrib.postgres | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Matthew Schinckel):

I'm not sure it's exactly the same issue: it's a different error message,
for one.

--
Ticket URL: <https://code.djangoproject.com/ticket/22962#comment:10>

Django

unread,
Mar 29, 2017, 6:09:55 AM3/29/17
to django-...@googlegroups.com
#22962: Default of [] for postgres array field results in migration application
failure.
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Marc
| Tamlyn <marc.tamlyn@…>
Type: Bug | Status: closed
Component: contrib.postgres | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Doug Whiteley):

* status: new => closed
* resolution: => fixed


Comment:

Reopened in error

--
Ticket URL: <https://code.djangoproject.com/ticket/22962#comment:11>

Reply all
Reply to author
Forward
0 new messages