Skip to content

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

Merged
jamis merged 1 commit intomongodb:masterfrom
jamis:3533-sortable-binary
Oct 14, 2024
Merged

RUBY-3533 Make BSON::Binary objects comparable#338
jamis merged 1 commit intomongodb:masterfrom
jamis:3533-sortable-binary

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
@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