Skip to content

Commit

Permalink
mongo aggregate查询加limit行数限制,防止返回结果过多导致archery挂掉 (hhyo#1948)
Browse files Browse the repository at this point in the history
* mongo aggregate查询加limit行数限制,防止返回结果过多导致archery挂掉

(cherry picked from commit 027904f)
  • Loading branch information
czxin788 authored and nick2wang committed Nov 8, 2022
1 parent f43f4fa commit 3de8a02
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sql/engines/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,8 @@ def query(self, db_name=None, sql="", limit_num=0, close_conn=True, **kwargs):
if "condition" in query_dict:
if method == "aggregate":
condition = query_dict["condition"]
# 给aggregate查询加limit行数限制,防止返回结果过多导致archery挂掉
condition.append({"$limit": limit_num})
if method == "find":
condition = de.decode(query_dict["condition"])
find_cmd += "(condition)"
Expand Down

0 comments on commit 3de8a02

Please sign in to comment.