Permalink
Browse files

Support SimpleUUID::UUID instances as well.

Since CassandraCQL::UUID just inherits from it, we might as well
support the whole family. I've already had a few times where I tried to
insert SimpleUUID::UUID's and it didn't work, which confused me.
  • Loading branch information...
jnunemaker committed Nov 8, 2012
1 parent 3393c97 commit 06d2a2a8b286570bcf7f8beff68a80de888d0a83
Showing with 9 additions and 1 deletion.
  1. +1 −1 lib/cassandra-cql/statement.rb
  2. +8 −0 spec/statement_spec.rb
@@ -90,7 +90,7 @@ def self.cast_to_cql(obj)
obj.strftime('%Y-%m-%d')
elsif obj.kind_of?(Time)
(obj.to_f * 1000).to_i
- elsif obj.kind_of?(UUID)
+ elsif obj.kind_of?(SimpleUUID::UUID)
obj.to_guid
# There are corner cases where this is an invalid assumption but they are extremely rare.
# The alternative is to make the user pack the data on their own .. let's not do that until we have to
View
@@ -130,6 +130,14 @@
end
end
+ context "with a SimpleUUID::UUID object" do
+ it "should return the guid" do
+ uuid = SimpleUUID::UUID.new
+ guid = Statement.cast_to_cql(uuid)
+ guid.should eq(uuid.to_guid)
+ end
+ end
+
context "with a String without quotes" do
it "should return a copy of itself" do
str = "This is a string"

0 comments on commit 06d2a2a

Please sign in to comment.