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

RUBY-3533 Make BSON::Binary objects comparable #338

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

jamis
Copy link
Contributor

@jamis jamis commented Oct 11, 2024

Because BSON::Binary instances represent binary data, it ought to be possible to compare their raw binary contents and decide which one would sort before or after another. This PR adds an implementation of #<=> to BSON::Binary. As long as both objects have the same binary type, this will compare the raw contents of the two objects, allowing homogeneous lists of BSON::Binary instances to be (e.g.) sorted.

The comparison is only meaningful if the two objects have the
same Binary type, as well.
@jamis jamis requested a review from comandeo-mongo October 11, 2024 17:41
@jamis jamis merged commit bc942e1 into mongodb:master Oct 14, 2024
47 checks passed
@jamis jamis deleted the 3533-sortable-binary branch October 14, 2024 14:25
@adam-hampton-sp
Copy link

Thank you for the new feature!

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.

3 participants