Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #9572 -- use `opts` argument. Thanks SeanL for bug report and p…

…atch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9572 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4058429708da7380385a28959ba10a51cda7f05a 1 parent 8370e7c
Justin Bronn authored December 06, 2008
2  django/contrib/gis/db/models/sql/query.py
@@ -122,7 +122,7 @@ def get_default_columns(self, with_aliases=False, col_aliases=None,
122 122
             table_alias = start_alias
123 123
         else:
124 124
             table_alias = self.tables[0]
125  
-        root_pk = self.model._meta.pk.column
  125
+        root_pk = opts.pk.column
126 126
         seen = {None: table_alias}
127 127
         aliases = set()
128 128
         for field, model in opts.get_fields_with_model():
9  django/contrib/gis/tests/relatedapp/models.py
@@ -11,3 +11,12 @@ class City(models.Model):
11 11
     state = USStateField()
12 12
     location = models.ForeignKey(Location)
13 13
     objects = models.GeoManager()
  14
+
  15
+class AugmentedLocation(Location):
  16
+    extra_text = models.TextField(blank=True)
  17
+    objects = models.GeoManager()
  18
+    
  19
+class DirectoryEntry(models.Model):
  20
+    listing_text = models.CharField(max_length=50)
  21
+    location = models.ForeignKey(AugmentedLocation)
  22
+    objects = models.GeoManager()
7  django/contrib/gis/tests/relatedapp/tests.py
@@ -2,7 +2,7 @@
2 2
 from django.contrib.gis.geos import *
3 3
 from django.contrib.gis.tests.utils import no_mysql, postgis
4 4
 from django.conf import settings
5  
-from models import City, Location
  5
+from models import City, Location, DirectoryEntry
6 6
 
7 7
 cities = (('Aurora', 'TX', -97.516111, 33.058333),
8 8
           ('Roswell', 'NM', -104.528056, 33.387222),
@@ -89,6 +89,11 @@ def test04_related_aggregate(self):
89 89
         u2 = City.objects.exclude(name='Roswell').unionagg(field_name='location__point')
90 90
         self.assertEqual(ref_u1, u1)
91 91
         self.assertEqual(ref_u2, u2)
  92
+        
  93
+    def test05_select_related_fk_to_subclass(self):
  94
+        "Testing that calling select_related on a query over a model with an FK to a model subclass works"
  95
+        # Regression test for #9752.
  96
+        l = list(DirectoryEntry.objects.all().select_related())
92 97
 
93 98
     # TODO: Related tests for KML, GML, and distance lookups.
94 99
         

0 notes on commit 4058429

Please sign in to comment.
Something went wrong with that request. Please try again.