Skip to content

Commit 569719b

Browse files
committed
Fixes for MongoRawQuery and MongoRawQuerySet
1 parent 63db8d4 commit 569719b

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

django_mongodb/query.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -326,21 +326,15 @@ def __init__(self, sql, using, model, params=()):
326326
self.model = model
327327

328328
def __iter__(self):
329-
self.cursor = self._execute_query()
330-
if not connections[self.using].features.can_use_chunked_reads:
331-
result = list(self.cursor)
332-
else:
333-
result = self.cursor
334-
return iter(result)
329+
self._execute_query()
330+
return self.cursor
335331

336332
def _execute_query(self):
337333
connection = connections[self.using]
338334
collection = connection.get_collection(self.model._meta.db_table)
339-
return collection.aggregate(self.sql)
335+
self.cursor = collection.aggregate(self.sql)
340336

341337
def get_columns(self):
342-
if self.cursor is None:
343-
self._execute_query()
344338
return [f.column for f in self.model._meta.fields]
345339

346340
def __str__(self):
@@ -358,7 +352,7 @@ def __init__(
358352
using=None,
359353
hints=None,
360354
):
361-
super().__init__(raw_query, model=model, query=query, using=using, hints=hints)
355+
super().__init__(raw_query, model=model, query=query, using=using, hints=hints, translations=translations)
362356
self.query = query or MongoRawQuery(
363357
sql=raw_query, using=self.db, model=self.model, params=params
364358
)

0 commit comments

Comments
 (0)