Skip to content
Snippets Groups Projects
Commit 0fbd5d9c authored by James Graham's avatar James Graham
Browse files

Avoid conversion via string when returning MongoDB records - #63

parent a406bd40
No related branches found
No related tags found
No related merge requests found
...@@ -162,10 +162,9 @@ class CsvToMongoConnector(InternalDataConnector, DataSetConnector): ...@@ -162,10 +162,9 @@ class CsvToMongoConnector(InternalDataConnector, DataSetConnector):
params = {key: _type_convert(val) for key, val in params.items()} params = {key: _type_convert(val) for key, val in params.items()}
with context_managers.switch_collection(CsvRow, self.location) as collection: with context_managers.switch_collection(CsvRow, self.location) as collection:
records = collection.objects.filter(**params) records = collection.objects.filter(**params).exclude('_id')
# To get dictionary from MongoEngine records we need to go via JSON string data = list(records.as_pymongo())
data = json.loads(records.exclude('_id').to_json())
# Couldn't store field 'id' in document - recover it # Couldn't store field 'id' in document - recover it
for item in data: for item in data:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment