Ticket #14648: 14648.1.diff

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

    diff -r 49abe8cefc7b django/contrib/gis/db/models/sql/compiler.py
    a b  
    5656                        col_aliases.add(col[1])
    5757                else:
    5858                    result.append(col.as_sql(qn, self.connection))
    59                    
     59
    6060                    if hasattr(col, 'alias'):
    6161                        aliases.add(col.alias)
    6262                        col_aliases.add(col.alias)
     
    169169        from extra selection SQL get resolved appropriately into Python
    170170        objects.
    171171        """
     172        if not hasattr(self.query, 'extra_select_fields'):
     173            return row
    172174        values = []
    173175        aliases = self.query.extra_select.keys()
    174176        if self.query.aggregates:
     
    190192                               self.query.extra_select_fields.get(a, None),
    191193                               self.connection)
    192194                  for v, a in izip(row[rn_offset:index_start], aliases)]
     195
    193196        if self.connection.ops.oracle or getattr(self.query, 'geo_values', False):
    194197            # We resolve the rest of the columns if we're on Oracle or if
    195198            # the `geo_values` attribute is defined.
     
    202205    #### Routines unique to GeoQuery ####
    203206    def get_extra_select_format(self, alias):
    204207        sel_fmt = '%s'
    205         if alias in self.query.custom_select:
     208        if alias in getattr(self.query, 'custom_select', {}):
    206209            sel_fmt = sel_fmt % self.query.custom_select[alias]
    207210        return sel_fmt
    208211
Back to Top