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

Fix the not exist case in $toInt and $toDecimal #612

Merged
merged 1 commit into from
Apr 3, 2020

Conversation

lxy1992
Copy link
Contributor

@lxy1992 lxy1992 commented Apr 1, 2020

It's the fix for the bug I mentioned in the last PR.

First, I thought it was a serious bug in _Parse function, so I haven't fix it in the last PR. Now, I believe it only affect the operators in the $addField operator. So, I fix them in this PR with UTs.

The case is, when we try to add a field from a field which is not exist, Mongo will return the new field with the value of None.

Now, the $toInt and $toDecimal operators will return the original query now. So I return None when the KeyError raised in these operators.

If you're convenient, please review and merge it.

Cheers!

@codecov
Copy link

codecov bot commented Apr 1, 2020

Codecov Report

Merging #612 into develop will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #612   +/-   ##
========================================
  Coverage    94.74%   94.75%           
========================================
  Files           16       16           
  Lines         3217     3223    +6     
========================================
+ Hits          3048     3054    +6     
  Misses         169      169           
Impacted Files Coverage Δ
mongomock/aggregate.py 97.03% <100.00%> (+0.02%) ⬆️

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 48f0d81...01268e5. Read the comment docs.

@lxy1992 lxy1992 changed the title $addField(fix): fix the not exist case in $toInt and $toDecimal Fix: fix the not exist case in $toInt and $toDecimal Apr 2, 2020
@lxy1992 lxy1992 changed the title Fix: fix the not exist case in $toInt and $toDecimal Fix the not exist case in $toInt and $toDecimal Apr 2, 2020
@lxy1992
Copy link
Contributor Author

lxy1992 commented Apr 2, 2020

I am working on another PR about $sum. I may finish it at this weekend. Looking forward your code review, thanks!

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.

Perfect, thanks.

Feel free to send a PR to add yourself as a contributor to this project in the main page.

@pcorpet pcorpet merged commit d385293 into mongomock:develop Apr 3, 2020
@lxy1992
Copy link
Contributor Author

lxy1992 commented Apr 3, 2020

OK, I will add this info in the next PR. Thanks!

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