Skip to content

PHPLIB-485: Inherit collection's typeMap in distinct #688

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

Merged
merged 1 commit into from
Oct 9, 2019

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Oct 8, 2019

* non-scalar values are sorted by running json_encode on them and
* comparing their string representations.
*/
$sort = function ($a, $b) {
Copy link
Member

Choose a reason for hiding this comment

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

Would it be easier to just assert that the count of $expectedDocuments and $values is equal and then loop over $expectedDocuments and assert that each of its elements exists in $values?

I realize the only scalar is 4 at the moment, but this seems like it could be fragile if additional scalars were added to the test data.

Copy link
Member Author

Choose a reason for hiding this comment

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

I shamelessly copied this from DistinctFunctionalTest, so I had to double-check what it does. This method generally sorts scalars to the top and non-scalars to the bottom, but each group is sorted within itself, so adding multiple scalars shouldn't pose an issue. Non-scalars are encoded to JSON before sorting, so they are sorted by their JSON representation.

@alcaeus alcaeus added the bug label Oct 9, 2019
@alcaeus alcaeus merged commit 32cfb9b into mongodb:v1.5 Oct 9, 2019
@alcaeus alcaeus deleted the phplib-485 branch October 9, 2019 14:34
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