Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make sure nil values cast to nil (not "")

  • Loading branch information...
commit a2740cd3a7f3fbf2c650e2e9c5bb8ad66ec5d48c 1 parent 257dcf6
Michael Rykov rykov authored
Showing with 9 additions and 0 deletions.
  1. +2 −0  lib/cassandra-cql/schema.rb
  2. +7 −0 spec/column_family_spec.rb
2  lib/cassandra-cql/schema.rb
View
@@ -60,6 +60,8 @@ def columns
end
def self.cast(value, type)
+ return nil if value.nil?
+
case type
when "org.apache.cassandra.db.marshal.TimeUUIDType"
UUID.to_time(value)
7 spec/column_family_spec.rb
View
@@ -87,6 +87,13 @@
obj = Object.new
ColumnFamily.cast(obj, "org.apache.cassandra.db.marshal.BytesType").object_id.should eq(obj.object_id)
end
+
+ it "should return nil for all types of nil" do
+ %w(TimeUUIDType UUIDType LongType IntegerType
+ UTF8Type AsciiType CounterColumnType).each do |type|
+ ColumnFamily.cast(nil, "org.apache.cassandra.db.marshal.#{type}").should eq(nil)
+ end
+ end
end
context "validations classes" do
Please sign in to comment.
Something went wrong with that request. Please try again.