@@ -320,25 +320,24 @@ def raw_mql(self, raw_query, params=(), translations=None, using=None):
320
320
)
321
321
322
322
class MongoRawQuery (RawQuery ):
323
- pass
324
- #def _execute_query(self):
325
- # connection = connections[self.using]
326
-
327
- # # Adapt parameters to the database, as much as possible considering
328
- # # that the target type isn't known. See #17755.
329
- # params_type = self.params_type
330
- # adapter = connection.ops.adapt_unknown_value
331
- # if params_type is tuple:
332
- # params = tuple(adapter(val) for val in self.params)
333
- # elif params_type is dict:
334
- # params = {key: adapter(val) for key, val in self.params.items()}
335
- # elif params_type is None:
336
- # params = None
337
- # else:
338
- # raise RuntimeError("Unexpected params type: %s" % params_type)
339
-
340
- # self.cursor = connection.cursor()
341
- # self.cursor.execute(self.sql, params)
323
+ def _execute_query (self ):
324
+ connection = connections [self .using ]
325
+
326
+ # Adapt parameters to the database, as much as possible considering
327
+ # that the target type isn't known. See #17755.
328
+ params_type = self .params_type
329
+ adapter = connection .ops .adapt_unknown_value
330
+ if params_type is tuple :
331
+ params = tuple (adapter (val ) for val in self .params )
332
+ elif params_type is dict :
333
+ params = {key : adapter (val ) for key , val in self .params .items ()}
334
+ elif params_type is None :
335
+ params = None
336
+ else :
337
+ raise RuntimeError ("Unexpected params type: %s" % params_type )
338
+
339
+ self .cursor = connection .cursor ()
340
+ self .cursor .execute (self .sql , params )
342
341
343
342
344
343
class MongoRawQuerySet (RawQuerySet ):
@@ -357,15 +356,13 @@ def __init__(
357
356
using = None ,
358
357
hints = None ,
359
358
):
360
- pass
361
- # self.raw_query = raw_query
362
- # self.model = model
363
- # self._db = using
364
- # self._hints = hints or {}
365
- # self.query = query or sql.RawQuery(sql=raw_query, using=self.db, params=params)
359
+ self .model = model
360
+ self ._db = using
361
+ self ._hints = hints or {}
362
+ self .query = query or MongoRawQuery (sql = raw_query , using = self .db , params = params )
366
363
# self.params = params
367
364
# self.translations = translations or {}
368
- # self._result_cache = None
365
+ self ._result_cache = None
369
366
# self._prefetch_related_lookups = ()
370
367
# self._prefetch_done = False
371
368
0 commit comments