Ticket #17876: load_fields-upd.diff

File load_fields-upd.diff, 2.0 KB (added by milosu, 13 years ago)

patch and test case

  • django/db/models/query.py

    diff -ruN -x settings.py -x '*.pyc' -x '*.stackdump' -x '*.orig' -x '*.rej' ../Django-1.4c1.orig/django/db/models/query.py ../Django-1.4c1/django/db/models/query.py
    old new  
    12661266        return None
    12671267
    12681268    if only_load:
    1269         load_fields = only_load.get(klass)
     1269        load_fields = only_load.get(klass) or set()
    12701270        # When we create the object, we will also be creating populating
    12711271        # all the parent classes, so traverse the parent classes looking
    12721272        # for fields that must be included on load.
  • tests/modeltests/defer/models.py

    diff -ruN -x settings.py -x '*.pyc' -x '*.stackdump' -x '*.orig' -x '*.rej' ../Django-1.4c1.orig/tests/modeltests/defer/models.py ../Django-1.4c1/tests/modeltests/defer/models.py
    old new  
    2222
    2323class BigChild(Primary):
    2424    other = models.CharField(max_length=50)
     25
     26class ChildProxy(Child):
     27    class Meta:
     28        proxy=True
  • tests/modeltests/defer/tests.py

    diff -ruN -x settings.py -x '*.pyc' -x '*.stackdump' -x '*.orig' -x '*.rej' ../Django-1.4c1.orig/tests/modeltests/defer/tests.py ../Django-1.4c1/tests/modeltests/defer/tests.py
    old new  
    33from django.db.models.query_utils import DeferredAttribute
    44from django.test import TestCase
    55
    6 from .models import Secondary, Primary, Child, BigChild
     6from .models import Secondary, Primary, Child, BigChild, ChildProxy
    77
    88
    99class DeferTests(TestCase):
     
    145145        obj.name = "bb"
    146146        obj.save()
    147147
     148        # using select related and only should not result in Exception
     149        for obj in ChildProxy.objects.all().select_related().only('id'):
     150            continue
Back to Top