Skip to content

Commit 448859b

Browse files
Luke Lovettbehackett
authored andcommitted
PYTHON-981 - Optimize looking for $out in aggregation pipeline.
1 parent 4487294 commit 448859b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pymongo/collection.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,10 +1645,8 @@ def aggregate(self, pipeline, **kwargs):
16451645
# Apply this Collection's read concern if $out is not in the
16461646
# pipeline.
16471647
if sock_info.max_wire_version >= 4 and 'readConcern' not in cmd:
1648-
for stage in cmd['pipeline']:
1649-
if '$out' in stage:
1650-
result = self._command(sock_info, cmd, slave_ok)
1651-
break
1648+
if pipeline and '$out' in pipeline[-1]:
1649+
result = self._command(sock_info, cmd, slave_ok)
16521650
else:
16531651
result = self._command(sock_info, cmd, slave_ok,
16541652
read_concern=self.read_concern)

0 commit comments

Comments
 (0)