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 query projections with numeric arrays #157

Merged
merged 4 commits into from
Jan 29, 2017

Conversation

alcaeus
Copy link
Owner

@alcaeus alcaeus commented Jan 28, 2017

This fixes an edge case described in #144 (comment). This PR hardens the detection for numeric arrays and uses the same detection used in the legacy driver (requires sequential indexes starting with 0).

Additionally, this PR throws a MongoException when a legacy projection is used and one of the fields given is not a string (e.g. ['field', true]).

@palmic I've tested the new version against the tests you wrote and everything works as expected. If you want to give your test suite a spin before I merge this, let me know. You can do this by replacing the requirement for the adapter in composer.json with "alcaeus/mongo-php-adapter": "dev-projection-with-numeric-keys". There shouldn't be any issues, but since I changed the detection of numeric arrays and you're apparently using hashes with numeric keys, there might be some edge cases you run into.

@palmic
Copy link

palmic commented Jan 28, 2017

Nice, this works, thank you!
Michal.

@alcaeus alcaeus added the bug label Jan 29, 2017
@alcaeus alcaeus added this to the 1.0.9 milestone Jan 29, 2017
@alcaeus alcaeus merged commit fea3f83 into 1.0.x Jan 29, 2017
@alcaeus alcaeus deleted the projection-with-numeric-keys branch January 29, 2017 08:35
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.

2 participants