Skip to content

Commit 0d35ec7

Browse files
committed
Merge pull request #349 from erans/master
Minor bug fixes + supprot for limit and skip in simple query
2 parents dc0f9a6 + 2dbcd88 commit 0d35ec7

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

redash/data/query_runner_mongodb.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ def query_runner(query):
179179
if "sort" in query_data and query_data["sort"]:
180180
s = []
181181
for field in query_data["sort"]:
182-
for k in field:
183-
s.append((k, field[k]))
182+
s.append((field["name"], field["direction"]))
184183

185184
if "fields" in query_data:
186185
f = query_data["fields"]
@@ -192,11 +191,18 @@ def query_runner(query):
192191
json_data = None
193192

194193
cursor = None
195-
if q:
194+
if q or (not q and not aggregate):
196195
if s:
197196
cursor = db[collection].find(q, f).sort(s)
198197
else:
199198
cursor = db[collection].find(q, f)
199+
200+
if "skip" in query_data:
201+
cursor = cursor.skip(query_data["skip"])
202+
203+
if "limit" in query_data:
204+
cursor = cursor.limit(query_data["limit"])
205+
200206
elif aggregate:
201207
r = db[collection].aggregate(aggregate)
202208
cursor = r["result"]

0 commit comments

Comments
 (0)