Ticket #15305: 15305.1.diff

File 15305.1.diff, 1.5 KB (added by jbronn, 13 years ago)
  • django/contrib/gis/db/models/sql/compiler.py

    diff -r e349ad1b2b34 django/contrib/gis/db/models/sql/compiler.py
    a b  
    171171        """
    172172        values = []
    173173        aliases = self.query.extra_select.keys()
    174         if self.query.aggregates:
    175             # If we have an aggregate annotation, must extend the aliases
    176             # so their corresponding row values are included.
    177             aliases.extend([None for i in xrange(len(self.query.aggregates))])
    178174
    179175        # Have to set a starting row number offset that is used for
    180176        # determining the correct starting row index -- needed for
  • django/contrib/gis/tests/relatedapp/tests.py

    diff -r e349ad1b2b34 django/contrib/gis/tests/relatedapp/tests.py
    a b  
    245245        self.assertEqual(1, len(vqs))
    246246        self.assertEqual(3, vqs[0]['num_books'])
    247247
     248    def test13c_count(self):
     249        "Testing `Count` aggregate with `.values()`.  See #15305."
     250        qs = Location.objects.filter(id=5).annotate(num_cities=Count('city')).values('id', 'point', 'num_cities')
     251        self.assertEqual(1, len(qs))
     252        self.assertEqual(2, qs[0]['num_cities'])
     253        self.assertTrue(isinstance(qs[0]['point'], GEOSGeometry))
     254
    248255    # TODO: The phantom model does appear on Oracle.
    249256    @no_oracle
    250257    def test13_select_related_null_fk(self):
Back to Top