Make array references behave like ordered hashes on cursor and collection #36

merged 0 commits into from Aug 12, 2014


None yet
3 participants

diegok commented Jul 12, 2012

I've make this work on some parts it was documented but wasn't working and I've added and documented on ensure_index().

I've also added some tests for these features. Please let me know if there is something I've missed.


edaniels commented Jul 23, 2014

This has become out of date with our current codebase. In we allow arrays in to_index_string. Regarding, I don't think the behavior of the _hash_or_sorted is particularly useful now. We document that the user should use Tie::IxHash if order matters and a IxHash can be deliberately made on the user's end. I do think that something needs to be done about Cursor::sort allowing hash refs since this can be a problem.

If you want, take a look at Collection::find and how it converts an array ref to an IxHash. Doing something similar for Cursor::sort and documenting the fact that the array ref needs to have an even number of elements would be beneficial. There should also be a warning that using hash refs can cause an unexpected sort result since ordering is in no way guaranteed by perl.


diegok commented Jul 23, 2014

Wow, has been 2y last ween since I've proposed this change!. Thank you for a response :-)

I'll read more carefully your response looking at current implementation since I still feel that something in this line would be a nice to have.

Hope to come back in less than 2y ! :-p


ghost commented Aug 1, 2014

I've created a Jira ticket (PERL-397) to track the broader issue that we need consistent treatment of ordered document arguments.

dagolden merged commit 4a66960 into mongodb:master Aug 12, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment