Implement the $split operator by khneal · Pull Request #661 · mongomock/mongomock

Conversation

@khneal

I didn't see any issues mentioning support for $split, but I figured a PR is better than filing an issue.

@pcorpet - Note the potential conflict with #658 in Missing_Features.rst. I don't mind fixing this PR if it's easier to merge that one first.

Let me know if any of the .gitignore entries are a problem.

Thanks!

@codecov

@khneal

Side note - it was a bit strange to see all operators tested simultaneously in test__aggregate_string_operations(). Is there a reason for that, like making the tests run faster? If not, I would consider breaking those apart in a future PR.

pcorpet

Choose a reason for hiding this comment

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

Thanks a lot for the implementation.

Can you update test__mongomock also, to make sure the behavior stays the same between pymongo + MongoDb and mongomock?

Also, I believe you have no test where the split operation references a variable that does not exist:

{'$split': ['$missingField', 'l']}

please add one.


#### Python
*.py[co]
/venv

Choose a reason for hiding this comment

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

Please drop the changes to this .gitignore file, and use a local gitignore instead.

Choose a reason for hiding this comment

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

Done. Good suggestion.

@khneal

Can you update test__mongomock also, to make sure the behavior stays the same between pymongo + MongoDb and mongomock?

Done.

Also, I believe you have no test where the split operation references a variable that does not exist:

Added. I almost committed one like that initially, but didn't see other string operations testing the same. I'm glad you pointed that out since it changed the implementation so the KeyError is caught, which in turn fixed a consistency issue I had in test__mongomock. Nice. 😃

@pcorpet

All good! Thanks for the quick turnaround. I'm going to merge now.

@khneal

Thank you! The PR process for this project was quick and easy, and kudos to you for all your efforts making it so.

I look forward to the next release. If there's a pre-release build available somewhere/somehow, I would be interested in pulling that into my workflow.

@khneal khneal deleted the feature/aggregate_split branch

August 19, 2020 18:43

2 participants

@khneal @pcorpet