Ticket #2479: aggregate.diff
File aggregate.diff, 984 bytes (added by , 18 years ago) |
---|
-
db/models/query.py
301 301 self._result_cache = None 302 302 delete.alters_data = True 303 303 304 def aggregrate(self, function, field): 305 """Performs a simple aggregate function on field""" 306 counter = self._clone() 307 counter._order_by = () 308 counter._offset = None 309 counter._limit = None 310 counter._select_related = False 311 select, sql, params = counter._get_sql_clause() 312 cursor = connection.cursor() 313 # absolutely no input checking 314 cursor.execute( "SELECT %s(%s)" % (function, backend.quote_name(field)) + sql, params) 315 return cursor.fetchone()[0] 316 317 304 318 ################################################## 305 319 # PUBLIC METHODS THAT RETURN A QUERYSET SUBCLASS # 306 320 ##################################################