@@ -309,19 +309,15 @@ def register_nodes():
309309
310310
311311class MongoQuerySet (QuerySet ):
312- def raw_mql (self , raw_query , translations = None , using = None ):
313- return MongoRawQuerySet (
314- raw_query ,
315- model = self .model ,
316- translations = translations ,
317- using = using ,
318- )
312+ def raw_mql (self , pipeline , using = None ):
313+ return MongoRawQuerySet (pipeline , model = self .model , using = using )
319314
320315
321316class MongoRawQuery (RawQuery ):
322- def __init__ (self , sql , using , model ):
323- super ().__init__ (sql , using )
317+ def __init__ (self , pipeline , using , model ):
318+ super ().__init__ (sql = None , using = using )
324319 self .model = model
320+ self .pipeline = pipeline
325321
326322 def __iter__ (self ):
327323 self ._execute_query ()
@@ -330,34 +326,34 @@ def __iter__(self):
330326 def _execute_query (self ):
331327 connection = connections [self .using ]
332328 collection = connection .get_collection (self .model ._meta .db_table )
333- self .cursor = collection .aggregate (self .sql )
329+ self .cursor = collection .aggregate (self .pipeline )
334330
335331 def get_columns (self ):
336332 return [f .column for f in self .model ._meta .fields ]
337333
338334 def __str__ (self ):
339- return "%s" % self .sql
335+ return "%s" % self .pipeline
340336
341337
342338class MongoRawQuerySet (RawQuerySet ):
343339 def __init__ (
344340 self ,
345- raw_query ,
341+ pipeline ,
346342 model = None ,
347343 query = None ,
348344 translations = None ,
349345 using = None ,
350346 hints = None ,
351347 ):
352348 super ().__init__ (
353- raw_query ,
349+ pipeline ,
354350 model = model ,
355351 query = query ,
356352 using = using ,
357353 hints = hints ,
358354 translations = translations ,
359355 )
360- self .query = query or MongoRawQuery (sql = raw_query , using = self .db , model = self .model )
356+ self .query = query or MongoRawQuery (pipeline , using = self .db , model = self .model )
361357
362358 def iterator (self ):
363359 yield from MongoRawModelIterable (self )
0 commit comments