Permalink
Browse files

Merge pull request #35 from jnunemaker/simpleuuid-support

Support SimpleUUID::UUID instances as well.
  • Loading branch information...
2 parents 3393c97 + 06d2a2a commit 012bd7037d28ac105e546f9c5db3568ea816cb79 @kreynolds committed Nov 8, 2012
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 012bd70

Please sign in to comment.