Revert ObjectId#to_ary #107
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The introduction of commit 078354a breaks any application that would attempt to flatten an array of object ids, forcing it to appear hung and never exiting (and really hard to debug for those who don't have a good knowledge of Ruby's core API). Since we do this in Mongoid, and I'm sure many others do, release 1.6.3 is unusable.
The proper implementation of this would be to return
nilfromBSON::ObjectId#to_aryin order to allow proper flattening as well as allowing forKernel.Arrayto work properly. HoweverBSON::ObjectIddoes not follow Ruby conventions with respect toBSON::ObjectId#to_aeither, which returns the internal data instead of the object id wrapped in an array.I was about to re-implement
BSON::ObjectId#to_aas well, however this has repercussions as there are current expectations around whatBSON::ObjectId#to_areturns in the driver albeit incorrect. So this pull is simply to get the driver back to a reusable state with tests aroundArray#flattenandArray#flatten!to ensure this isn't broken again.There needs to be an overhaul of this class with regards to core Ruby APIs and what they are expected to return, as simple changes like this have rippling affects.
BSON::ObjectId#to_aneeds to change to adhere to this, but it's going to break other things as well. IMO it's best to stay with the existing functionality to not be breaking apps in patch releases.