Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project missing fields in a nested dict fix #605

Merged
merged 2 commits into from
Mar 16, 2020

Conversation

superqwer
Copy link
Contributor

@superqwer superqwer commented Mar 11, 2020

Current behavior of mongomock is "Ignore the whole dictionary if we couldn't find a single key"

That's not what the real mongo does

The real mongo just ignores this missing key

> db.asdf.aggregate([{'$project': {'a': 1, 'b': {'c': '$b'}}}])
{ "_id" : ObjectId("5e6875c3c3b830d2aaf259e5"), "a" : 1, "b" : {  } }

@codecov
Copy link

codecov bot commented Mar 11, 2020

Codecov Report

Merging #605 into develop will not change coverage by %.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #605   +/-   ##
========================================
  Coverage    94.69%   94.69%           
========================================
  Files           16       16           
  Lines         3187     3187           
========================================
  Hits          3018     3018           
  Misses         169      169           
Impacted Files Coverage Δ
mongomock/aggregate.py 96.88% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 768ec70...36aab18. Read the comment docs.

Copy link
Member

@pcorpet pcorpet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding the bug and fixing it.

@@ -3068,6 +3068,17 @@ def test__aggregate_project_missing_fields(self):
])
self.assertEqual([{}], list(actual))

def test__aggregate_project_missing_nested_fields(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an equivalent test in test__mongomock to ensure the behavior is kept the same between pymongo and mongomock

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@superqwer
Copy link
Contributor Author

Added similar testcase to test_mongomock

@superqwer superqwer requested a review from pcorpet March 11, 2020 10:35
@pcorpet pcorpet merged commit 1032643 into mongomock:develop Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants