From d788830df657e76bf373d752477b2c104ec056ef Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Fri, 11 May 2012 14:52:21 -0500 Subject: [PATCH] another mongodb improvement --- VERSION | 2 +- gluon/dal.py | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/VERSION b/VERSION index 2b8e3582..39b7f23a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-05-11 08:30:34) dev +Version 2.00.0 (2012-05-11 14:51:42) dev diff --git a/gluon/dal.py b/gluon/dal.py index 119f6980..556e1597 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -4523,24 +4523,23 @@ class MongoDBAdapter(NoSQLAdapter): print "mongo_list_dicts=%s" % mongo_list_dicts rows = [] ### populate row in proper order - if mongo_list_dicts: - def fix(id): return 'id' if id=='_id' else id - colnames = [fix(column) for column in mongo_list_dicts[0]] - else: - colnames = [] + colnames = [field.name for field in fields] for k,record in enumerate(mongo_list_dicts): row=[] - for column in record: - if column == '_id' and \ - isinstance(record[column],pymongo.objectid.ObjectId): - value = int(str(record[column]),16) - elif column != '_id': - value = record[column] + for colname in colnames: + column = '_id' if colname=='id' else colname + if column in record: + if column == '_id' and isinstance( + record[column],pymongo.objectid.ObjectId): + value = int(str(record[column]),16) + elif column != '_id': + value = record[column] + else: + value = None + else: + value = None row.append(value) rows.append(row) - - table = self.db[tablename] - fields = [table[colname] for colname in colnames] processor = attributes.get('processor',self.parse) return processor(rows,fields,colnames,False)