@@ -319,8 +319,6 @@ def raw_mql(self, raw_query, params=(), translations=None, using=None):
319319
320320
321321class MongoRawQuery (RawQuery ):
322-
323-
324322 def __init__ (self , sql , using , model , params = ()):
325323 self .params = params
326324 self .sql = sql
@@ -351,30 +349,32 @@ def __iter__(self):
351349
352350 def _execute_query (self ):
353351 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)
364363
365364 # self.cursor = connection.cursor()
366365 # self.cursor.execute(self.sql, params)
367366
368367 collection = connection .get_collection (self .model ._meta .db_table )
369-
368+
370369 return collection .aggregate (self .sql )
371370
372371 def get_columns (self ):
373372 if self .cursor is None :
374373 self ._execute_query ()
375374 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 ()]
378378
379379
380380class MongoRawQuerySet (RawQuerySet ):
@@ -391,6 +391,8 @@ def __init__(
391391 self .model = model
392392 self ._db = using
393393 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+ )
395397 self ._result_cache = None
396398 self .translations = translations or {}
0 commit comments