Author: ccahoon
Date: 2009-06-12 22:29:17 -0500 (Fri, 12 Jun 2009)
New Revision: 10996

Modified:
   
django/branches/soc2009/http-wsgi-improvements/tests/regressiontests/defer_regress/models.py
Log:
Fixed #10733 -- Added a regression test for queries with multiple references to 
multiple foreign keys in only() clauses. Thanks to mrts for the report.

Modified: 
django/branches/soc2009/http-wsgi-improvements/tests/regressiontests/defer_regress/models.py
===================================================================
--- 
django/branches/soc2009/http-wsgi-improvements/tests/regressiontests/defer_regress/models.py
        2009-06-13 03:29:07 UTC (rev 10995)
+++ 
django/branches/soc2009/http-wsgi-improvements/tests/regressiontests/defer_regress/models.py
        2009-06-13 03:29:17 UTC (rev 10996)
@@ -84,7 +84,8 @@
 (regression for #10710).
 
 >>> c1 = Child.objects.create(name="c1", value=42)
->>> obj = Leaf.objects.create(name="l1", child=c1)
+>>> c2 = Child.objects.create(name="c2", value=37)
+>>> obj = Leaf.objects.create(name="l1", child=c1, second_child=c2)
 
 >>> obj = Leaf.objects.only("name", "child").select_related()[0]
 >>> obj.child.name
@@ -101,5 +102,24 @@
 >>> c1 is c2 is c3
 True
 
+# Regression for #10733 - only() can be used on a model with two foreign keys.
+>>> results = Leaf.objects.all().only('name', 'child', 
'second_child').select_related()
+>>> results[0].child.name
+u'c1'
+>>> results[0].second_child.name
+u'c2'
+
+>>> results = Leaf.objects.all().only('name', 'child', 'second_child', 
'child__name', 'second_child__name').select_related()
+>>> results[0].child.name
+u'c1'
+>>> results[0].second_child.name
+u'c2'
+
+# Finally, we need to flush the app cache for the defer module.
+# Using only/defer creates some artifical entries in the app cache
+# that messes up later tests. Purge all entries, just to be sure.
+>>> from django.db.models.loading import cache
+>>> cache.app_models['defer_regress'] = {}
+
 """
 }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to