@@ -319,8 +319,6 @@ def raw_mql(self, raw_query, params=(), translations=None, using=None):
319
319
320
320
321
321
class MongoRawQuery (RawQuery ):
322
-
323
-
324
322
def __init__ (self , sql , using , model , params = ()):
325
323
self .params = params
326
324
self .sql = sql
@@ -351,30 +349,32 @@ def __iter__(self):
351
349
352
350
def _execute_query (self ):
353
351
connection = connections [self .using ]
354
- params_type = self .params_type
355
- adapter = connection .ops .adapt_unknown_value
356
- if params_type is tuple :
357
- params = tuple (adapter (val ) for val in self .params )
358
- elif params_type is dict :
359
- params = {key : adapter (val ) for key , val in self .params .items ()}
360
- elif params_type is None :
361
- params = None
362
- else :
363
- raise RuntimeError ("Unexpected params type: %s" % params_type )
352
+ # params_type = self.params_type
353
+ # adapter = connection.ops.adapt_unknown_value
354
+
355
+ # if params_type is tuple:
356
+ # params = tuple(adapter(val) for val in self.params)
357
+ # elif params_type is dict:
358
+ # params = {key: adapter(val) for key, val in self.params.items()}
359
+ # elif params_type is None:
360
+ # params = None
361
+ # else:
362
+ # raise RuntimeError("Unexpected params type: %s" % params_type)
364
363
365
364
# self.cursor = connection.cursor()
366
365
# self.cursor.execute(self.sql, params)
367
366
368
367
collection = connection .get_collection (self .model ._meta .db_table )
369
-
368
+
370
369
return collection .aggregate (self .sql )
371
370
372
371
def get_columns (self ):
373
372
if self .cursor is None :
374
373
self ._execute_query ()
375
374
converter = connections [self .using ].introspection .identifier_converter
376
- self .cursor .description = ""
377
- return [converter (column_meta [0 ]) for column_meta in self .cursor .description ]
375
+ # self.cursor.description = ""
376
+ # return [converter(column_meta[0]) for column_meta in self.cursor.description]
377
+ return [converter (column_name ) for column_name in self .model ._meta .get_fields ()]
378
378
379
379
380
380
class MongoRawQuerySet (RawQuerySet ):
@@ -391,6 +391,8 @@ def __init__(
391
391
self .model = model
392
392
self ._db = using
393
393
self ._hints = hints or {}
394
- self .query = query or MongoRawQuery (sql = raw_query , using = self .db , model = self .model , params = params )
394
+ self .query = query or MongoRawQuery (
395
+ sql = raw_query , using = self .db , model = self .model , params = params
396
+ )
395
397
self ._result_cache = None
396
398
self .translations = translations or {}
0 commit comments