Skip to content

Commit 5329e59

Browse files
committed
Updated aggregate parameter PYTHON-366
1 parent de6598c commit 5329e59

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

pymongo/collection.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ def options(self):
889889

890890
return options
891891

892-
def aggregate(self, ops):
892+
def aggregate(self, pipeline):
893893
"""Perform an aggregation using the aggregation framework on this
894894
collection.
895895
@@ -901,7 +901,7 @@ def aggregate(self, ops):
901901
`aggregate command`_. will be sent to a secondary or slave.
902902
903903
:Parameters:
904-
- `ops`: a single command or list of aggregation commands
904+
- `pipeline`: a single command or list of aggregation commands
905905
906906
.. note:: Requires server version **>= 2.1.1**
907907
@@ -910,16 +910,16 @@ def aggregate(self, ops):
910910
.. _aggregate command:
911911
http://docs.mongodb.org/manual/applications/aggregation
912912
"""
913-
if not isinstance(ops, (dict, list, tuple)):
914-
raise TypeError("ops must be a dict, list or tuple")
913+
if not isinstance(pipeline, (dict, list, tuple)):
914+
raise TypeError("pipeline must be a dict, list or tuple")
915915

916-
if isinstance(ops, dict):
917-
ops = [ops]
916+
if isinstance(pipeline, dict):
917+
pipeline = [pipeline]
918918

919919
use_master = not self.slave_okay and not self.read_preference
920920

921921
return self.__database.command("aggregate", self.__name,
922-
pipeline=ops,
922+
pipeline=pipeline,
923923
read_preference=self.read_preference,
924924
slave_okay=self.slave_okay,
925925
_use_master=use_master)

test/test_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,11 +1056,11 @@ def test_aggregate(self):
10561056

10571057
self.assertRaises(TypeError, db.test.aggregate, "wow")
10581058

1059-
ops = {"$project": {"_id": False, "foo": True}}
1059+
pipeline = {"$project": {"_id": False, "foo": True}}
10601060
expected = {'ok': 1.0, 'result': [{'foo': [1, 2]}]}
1061-
self.assertEqual(expected, db.test.aggregate(ops))
1062-
self.assertEqual(expected, db.test.aggregate([ops]))
1063-
self.assertEqual(expected, db.test.aggregate((ops,)))
1061+
self.assertEqual(expected, db.test.aggregate(pipeline))
1062+
self.assertEqual(expected, db.test.aggregate([pipeline]))
1063+
self.assertEqual(expected, db.test.aggregate((pipeline,)))
10641064

10651065
def test_group(self):
10661066
db = self.db

0 commit comments

Comments
 (0)