diff --git a/redash/query_runner/mongodb.py b/redash/query_runner/mongodb.py index f0dc200cbd..3d2c5578d5 100644 --- a/redash/query_runner/mongodb.py +++ b/redash/query_runner/mongodb.py @@ -185,12 +185,11 @@ def run_query(self, query): else: collection = query_data["collection"] - q = None + q = query_data.get("query", None) f = None - aggregate = None - if "aggregate" in query_data: - aggregate = query_data["aggregate"] + aggregate = query_data.get("aggregate", None) + if aggregate: for step in aggregate: if "$sort" in step: sort_list = [] @@ -199,9 +198,7 @@ def run_query(self, query): step["$sort"] = SON(sort_list) - if aggregate: - pass - else: + if not aggregate: s = None if "sort" in query_data and query_data["sort"]: s = []