Ticket #9752: update-get-default-columns-plus-regression-test.patch

File update-get-default-columns-plus-regression-test.patch, 2.6 KB (added by Sean Legassick, 16 years ago)
  • django/contrib/gis/db/models/sql/query.py

     
    122122            table_alias = start_alias
    123123        else:
    124124            table_alias = self.tables[0]
    125         root_pk = self.model._meta.pk.column
     125        root_pk = opts.pk.column
    126126        seen = {None: table_alias}
     127        qn = self.quote_name_unless_alias
     128        qn2 = self.connection.ops.quote_name
    127129        aliases = set()
    128130        for field, model in opts.get_fields_with_model():
    129131            try:
  • django/contrib/gis/tests/relatedapp/tests.py

     
    22from django.contrib.gis.geos import *
    33from django.contrib.gis.tests.utils import no_mysql, postgis
    44from django.conf import settings
    5 from models import City, Location
     5from models import City, Location, DirectoryEntry
    66
    77cities = (('Aurora', 'TX', -97.516111, 33.058333),
    88          ('Roswell', 'NM', -104.528056, 33.387222),
     
    8989        u2 = City.objects.exclude(name='Roswell').unionagg(field_name='location__point')
    9090        self.assertEqual(ref_u1, u1)
    9191        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        # Obscure case, but I found breakage here in my own app so this acts as a regression test for my
     96        # patch that fixes it.
     97        # without patch this line will throw an exception
     98        l = list(DirectoryEntry.objects.all().select_related())
    9299
    93100    # TODO: Related tests for KML, GML, and distance lookups.
    94101       
  • django/contrib/gis/tests/relatedapp/models.py

     
    1111    state = USStateField()
    1212    location = models.ForeignKey(Location)
    1313    objects = models.GeoManager()
     14
     15class AugmentedLocation(Location):
     16    extra_text = models.TextField(blank=True)
     17    objects = models.GeoManager()
     18   
     19class DirectoryEntry(models.Model):
     20    listing_text = models.CharField(max_length=50)
     21    location = models.ForeignKey(AugmentedLocation)
     22    objects = models.GeoManager()
Back to Top