~ubuntu-branches/ubuntu/maverick/python-django/maverick

« back to all changes in this revision

Viewing changes to django/db/models/sql/aggregates.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.1.10 upstream) (4.4.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100521075255-i1zpeyc0k8512pd7
Tags: 1.2-1
New upstream stable release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
        if isinstance(self.col, (list, tuple)):
73
73
            self.col = (change_map.get(self.col[0], self.col[0]), self.col[1])
74
74
 
75
 
    def as_sql(self, quote_func=None):
 
75
    def as_sql(self, qn, connection):
76
76
        "Return the aggregate, rendered as SQL."
77
 
        if not quote_func:
78
 
            quote_func = lambda x: x
79
77
 
80
78
        if hasattr(self.col, 'as_sql'):
81
 
            field_name = self.col.as_sql(quote_func)
 
79
            field_name = self.col.as_sql(qn, connection)
82
80
        elif isinstance(self.col, (list, tuple)):
83
 
            field_name = '.'.join([quote_func(c) for c in self.col])
 
81
            field_name = '.'.join([qn(c) for c in self.col])
84
82
        else:
85
83
            field_name = self.col
86
84
 
127
125
    def __init__(self, col, sample=False, **extra):
128
126
        super(Variance, self).__init__(col, **extra)
129
127
        self.sql_function = sample and 'VAR_SAMP' or 'VAR_POP'
130