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 detection of empty keys in arrays and objects #203

Merged
merged 4 commits into from
Sep 22, 2017

Conversation

alcaeus
Copy link
Owner

@alcaeus alcaeus commented Sep 22, 2017

This pull request supersedes #196 and improves the checks used. The MongoCollection::checkKeys method already checks for empty keys, but didn't recursively check nested arrays and objects, which caused the original error.

While fixing this, I realized that the code to check whether the given value is an array or object in MongoCollection::insert was incomplete, so that was improved. Last but not least, MongoCollection::update may also take an array or object according to the driver code (which conflicts the official documentation), so the method signature was updated accordingly. As this is considered a bug fix this does not constitute a BC break; the original BC break was me adding the wrong typehint in the first place.

The empty key check needs to recurse into nested arrays and objects. This fixes an error where using a document with an empty key in an atomic update operator wasn't properly detected.
@alcaeus alcaeus added this to the 1.1.3 milestone Sep 22, 2017
@alcaeus alcaeus self-assigned this Sep 22, 2017
@alcaeus alcaeus added the bug label Sep 22, 2017
@alcaeus alcaeus merged commit 8415fd8 into master Sep 22, 2017
@alcaeus alcaeus deleted the fix-nested-empty-keys branch September 22, 2017 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant