-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: BSON
-
None
-
Fully Compatible
-
Ruby Drivers
-
Needed
-
Using Ruby BSON gem, release `bson (5.0.0)`. The BSON::Binary class is not compatible with Ruby's native sorting implementation. This can be seen with the `SortedSet` and simple `Array` Ruby classes.
Binary data is completely sortable. This is especially true for Binary Data that encodes UUIDs, which is what we are desire for our specific use case.
Example:
```
ss = SortedSet[]
bb1 = BSON::Binary.from_uuid(SecureRandom.uuid, :standard)
bb2 = BSON::Binary.from_uuid(SecureRandom.uuid, :standard)
- The first add performs no comparisons, so it succeeds.
ss.add(bb1)
- The second add call compares, and fails.
ss.add(bb2)
(irb):13:in `<main>': comparison of BSON::Binary with BSON::Binary failed (ArgumentError)
@hash[o] = true
^^^^^^^^^
- The same thing happens with arrays:
a1 = [bb1, bb2]
a1.sort
(irb):18:in `sort': comparison of BSON::Binary with BSON::Binary failed (ArgumentError)
from (irb):18:in `<main>'
```