iconara / cql-rb

Cassandra CQL 3 binary protocol driver for Ruby
106 stars 31 forks source link

Allows TimeUuid and Uuid to be compared for equality #111

Closed jasonmk closed 10 years ago

jasonmk commented 10 years ago

Currently, if you try to compare a Uuid and TimeUuid, there's some weirdness because of how Comparable implements ==.

[2] pry(main)> id = Cql::TimeUuid::Generator.new.next => #<Cql::TimeUuid:0x00000001d6fe88 @n=198073153519907614003849507369077940458> [3] pry(main)> id2 = Cql::Uuid.new(id.value) => #<Cql::Uuid:0x00000001d9df40 @n=198073153519907614003849507369077940458> [4] pry(main)> id2 == id => true [5] pry(main)> id == id2 => false

This patch reverses the order of operations allowing a Uuid and TimeUuid with the same value to be equal.

iconara commented 10 years ago

Good catch. I've merged it (minus some unrelated whitespace changes) and it will be released with the next patch release.