improve aggregation expression parsing by reyannh · Pull Request #619 · mongomock/mongomock
Conversation
Make expressions starting with $$ROOT or $$CURRENT work on documents with array of embedded documents fields.
Consider the following document dict:
{'name': 'foo', 'errors': [{'error_type': 1, 'description': 'problem 1'}, {'error_type': 2, 'description': 'problem 2'}], '_id': ObjectId('5e8c9ac81e957db62b16b888')}
And the expression - $$ROOT.errors.error_type
Current code will throw KeyError exception - {KeyError}2
Thanks for suggesting this improvement. Please add some tests in test__mongomock, both to check that the behavior is the same as with pymongo + MongoDb and that your feature doesn't get broken by a later refactoring.
robberry90 pushed a commit to robberry90/mongomock that referenced this pull request
Feb 4, 2023Co-authored-by: Pascal Corpet <pascal@bayesimpact.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters