Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25867 closed Bug (fixed)

Nested ArrayField cause error in system check on 1.9

Reported by: MP Owned by: Simon Charette
Component: contrib.postgres Version: 1.9
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Nested ArrayField generates an error during check errors in 1.9, but works on 1.8.7

Using a nested ArrayField from the docs will cause the error in 1.9:

To recreate, in a fresh project add the following models.py:

from django.contrib.postgres.fields import ArrayField
from django.db import models

class Board(models.Model):
    pieces = ArrayField(ArrayField(models.IntegerField()))

When you runserver the system check fails:

Unhandled exception in thread started by <function wrapper at 0xb61e3844>
Traceback (most recent call last):
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run
    self.check(display_num_errors=True)
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/core/checks/model_checks.py", line 28, in check_all_models
    errors.extend(model.check(**kwargs))
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/db/models/base.py", line 1170, in check
    errors.extend(cls._check_fields(**kwargs))
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/db/models/base.py", line 1247, in _check_fields
    errors.extend(field.check(**kwargs))
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/contrib/postgres/fields/array.py", line 49, in check
    base_errors = self.base_field.check()
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/contrib/postgres/fields/array.py", line 49, in check
    base_errors = self.base_field.check()
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1820, in check
    errors = super(IntegerField, self).check(**kwargs)
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 208, in check
    errors.extend(self._check_backend_specific_checks(**kwargs))
  File "/home/vagrant/.virtualenvs/djangotest/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 314, in _check_backend_specific_checks
    app_label = self.model._meta.app_label
AttributeError: 'IntegerField' object has no attribute 'model'

Change History (5)

comment:1 by Simon Charette, 9 years ago

Owner: set to Simon Charette
Severity: NormalRelease blocker
Status: newassigned
Triage Stage: UnreviewedAccepted

I have a patch in mind.

comment:2 by Simon Charette, 9 years ago

Has patch: set

comment:3 by Tim Graham, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Simon Charette <charette.s@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 59b57e6:

Fixed #25867 -- Fixed a system check crash with nested ArrayFields.

Thanks to Jean Gourds for the report, Tim and Claude for the review.

comment:5 by Simon Charette <charette.s@…>, 9 years ago

In c0da5980:

[1.9.x] Fixed #25867 -- Fixed a system check crash with nested ArrayFields.

Thanks to Jean Gourds for the report, Tim and Claude for the review.

Backport of 59b57e672c2f5a685804cce253d2c5314c45c5fa from master

Note: See TracTickets for help on using tickets.
Back to Top