Opened 10 years ago
Closed 8 years ago
#22962 closed Bug (fixed)
Default of [] for postgres array field results in migration application failure.
Reported by: | Matthew Schinckel | Owned by: | |
---|---|---|---|
Component: | contrib.postgres | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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:
Change History (11)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
In ArrayField.get_prep_value(self,value)
, adding:
if value == '[]': value = '{}'
makes it work as expected.
comment:3 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → Bug |
comment:4 by , 10 years ago
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.
comment:5 by , 10 years ago
Has patch: | set |
---|
comment:6 by , 10 years ago
Owner: | set to |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:9 by , 8 years ago
Resolution: | fixed |
---|---|
Status: | closed → new |
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.
comment:10 by , 8 years ago
I'm not sure it's exactly the same issue: it's a different error message, for one.
Oh, it was an undimensioned array: not sure if that's important.