Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#17876 closed Bug (fixed)

get_klass_info should handle proxy models and with select_related

Reported by: milosu Owned by: Karen Tracey
Component: Database layer (models, ORM) Version: 1.4-beta-1
Severity: Release blocker Keywords: proxy select_related get_klass_info
Cc: charette.s@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If I do not apply attached patch to django/db/models/query.py, the following test case fails:

======================================================================
ERROR: test_defer (modeltests.defer.tests.DeferTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\django_versions\Django-1.4c1\tests\modeltests\defer\tests.py", line 149, in test_defer
    for obj in ChildProxy.objects.all().select_related().only('id'):
  File "C:\Python26\lib\site-packages\django_versions\Django-1.4c1\django\db\models\query.py", line 118, in _result_iter
    self._fill_cache()
  File "C:\Python26\lib\site-packages\django_versions\Django-1.4c1\django\db\models\query.py", line 875, in _fill_cache
    self._result_cache.append(self._iter.next())
  File "C:\Python26\lib\site-packages\django_versions\Django-1.4c1\django\db\models\query.py", line 290, in iterator
    requested=requested, only_load=only_load)
  File "C:\Python26\lib\site-packages\django_versions\Django-1.4c1\django\db\models\query.py", line 1276, in get_klass_info
    load_fields.update(fields)
AttributeError: 'NoneType' object has no attribute 'update'

----------------------------------------------------------------------
Ran 170 tests in 0.700s

FAILED (errors=1)

Attachments (2)

load_fields-upd.diff (2.0 KB ) - added by milosu 13 years ago.
patch and test case
better_test.diff (958 bytes ) - added by Przemek Lewandowski <prze.lewandowski@…> 13 years ago.
Patch with improved test.

Download all attachments as: .zip

Change History (7)

by milosu, 13 years ago

Attachment: load_fields-upd.diff added

patch and test case

comment:1 by Simon Charette, 13 years ago

Cc: charette.s@… added
Keywords: proxy select_related get_klass_info added
Triage Stage: UnreviewedAccepted

I can confirm the attached testcase fails with 1.4-rc-1 but pass with 1.3.1 thus marking as Release blocker.

comment:2 by anonymous, 13 years ago

Owner: changed from nobody to anonymous

comment:3 by Karen Tracey, 13 years ago

Owner: changed from anonymous to Karen Tracey

comment:4 by Karen Tracey, 13 years ago

Resolution: fixed
Status: newclosed

In [17692]:

Fix #17876: Corrected an exception (regression) raised where select_realted and only is used on a proxy model. Thanks milosu and charettes.

by Przemek Lewandowski <prze.lewandowski@…>, 13 years ago

Attachment: better_test.diff added

Patch with improved test.

comment:5 by Karen Tracey, 13 years ago

In [17695]:

Refs #17876: enhanced new test to actually test underlying function, not just ensure trying to use it does not raise an exception. Thanks Przemek Lewandowski.

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