Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#17876 closed Bug (fixed)

get_klass_info should handle proxy models and with select_related

Reported by: milosu Owned by: kmtracey
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


If I do not apply attached patch to django/db/models/, 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\", 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\", line 118, in _result_iter
  File "C:\Python26\lib\site-packages\django_versions\Django-1.4c1\django\db\models\", line 875, in _fill_cache
  File "C:\Python26\lib\site-packages\django_versions\Django-1.4c1\django\db\models\", line 290, in iterator
    requested=requested, only_load=only_load)
  File "C:\Python26\lib\site-packages\django_versions\Django-1.4c1\django\db\models\", line 1276, in get_klass_info
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 4 years ago.
patch and test case
better_test.diff (958 bytes) - added by Przemek Lewandowski <prze.lewandowski@…> 4 years ago.
Patch with improved test.

Download all attachments as: .zip

Change History (7)

Changed 4 years ago by milosu

patch and test case

comment:1 Changed 4 years ago by charettes

  • Cc charette.s@… added
  • Keywords proxy select_related get_klass_info added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 4 years ago by anonymous

  • Owner changed from nobody to anonymous

comment:3 Changed 4 years ago by kmtracey

  • Owner changed from anonymous to kmtracey

comment:4 Changed 4 years ago by kmtracey

  • Resolution set to fixed
  • Status changed from new to closed

In [17692]:

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

Changed 4 years ago by Przemek Lewandowski <prze.lewandowski@…>

Patch with improved test.

comment:5 Changed 4 years ago by kmtracey

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