Skip to content

Conversation

@fattymiller
Copy link

@fattymiller fattymiller commented Aug 15, 2018

When performing an Array#uniq with two GlobalID objects that are ==, the result of the uniq still contains the "duplicate" entries.

This PR changes the hash method to consider the hash of the underlaying URI hash so that two GlobalID objects pointing to the same object are considered duplicates of each other.

Previously, with:
p1 = GlobalID.create(Person.new(1))
p2 = GlobalID.create(Person.new(1))

p1 == p2 #=> true but [p1, p2].uniq #=> [p1, p2]

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @kaspth (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rafaelfranca rafaelfranca merged commit 288ac24 into rails:master Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants