Skip to content
This repository
Browse code

Adding an Avg aggregate

  • Loading branch information...
commit 1c1b5761d0c767610b23c9a72eef978649a2bb21 1 parent 3628fcf
Charles Leifer authored August 06, 2012

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. 5  peewee.py
5  peewee.py
@@ -35,7 +35,7 @@
35 35
 
36 36
 __all__ = [
37 37
     'ImproperlyConfigured', 'SqliteDatabase', 'MySQLDatabase', 'PostgresqlDatabase',
38  
-    'asc', 'desc', 'Count', 'Max', 'Min', 'Sum', 'Q', 'Field', 'CharField', 'TextField',
  38
+    'asc', 'desc', 'Count', 'Max', 'Min', 'Sum', 'Avg', 'Q', 'Field', 'CharField', 'TextField',
39 39
     'DateTimeField', 'BooleanField', 'DecimalField', 'FloatField', 'IntegerField',
40 40
     'PrimaryKeyField', 'ForeignKeyField', 'DoubleField', 'BigIntegerField', 'Model',
41 41
     'filter_query', 'annotate_query', 'F', 'R', 'DateField', 'TimeField',
@@ -781,6 +781,9 @@ def Min(f, alias='min'):
781 781
 def Sum(f, alias='sum'):
782 782
     return ('SUM', f, alias)
783 783
 
  784
+def Avg(f, alias='avg'):
  785
+    return ('AVG', f, alias)
  786
+
784 787
 # decorator for query methods to indicate that they change the state of the
785 788
 # underlying data structures
786 789
 def returns_clone(func):

0 notes on commit 1c1b576

Please sign in to comment.
Something went wrong with that request. Please try again.