Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

On mock connection insert(), map the column names being inserted to t…

…he schema-specified types instead of assuming them to be StringType
  • Loading branch information...
commit 90baff94d2ed032a966d79ebf259b9a68dd3650a 1 parent 67f7a9a
Ilya Kirnos authored
Showing with 15 additions and 2 deletions.
  1. +15 −2 lib/cassandra/mock.rb
View
17 lib/cassandra/mock.rb
@@ -58,8 +58,15 @@ def insert(column_family, key, hash_or_array, options = {})
end
def insert_standard(column_family, key, hash_or_array)
+ validated_column_value_hash = {}
+ hash_or_array.each do |column_name, value|
+ column_family, validated_column, _, _ =
+ extract_and_validate_params_for_real(column_family, [key], [column_name], READ_DEFAULTS)
+ validated_column_value_hash[validated_column] = value
+ end
+
old = cf(column_family)[key] || OrderedHash.new
- cf(column_family)[key] = merge_and_sort(old, hash_or_array)
+ cf(column_family)[key] = merge_and_sort(old, validated_column_value_hash)
end
def insert_super(column_family, key, hash)
@@ -67,8 +74,14 @@ def insert_super(column_family, key, hash)
cf(column_family)[key] ||= OrderedHash.new
hash.keys.each do |sub_key|
+ validated_column_value_hash = {}
+ hash[sub_key].each do |column_name, value|
+ column_family, validated_column, _, _ =
+ extract_and_validate_params_for_real(column_family, [key], [sub_key,column_name], READ_DEFAULTS)
+ validated_column_value_hash[validated_column] = value
+ end
old = cf(column_family)[key][sub_key] || OrderedHash.new
- cf(column_family)[key][sub_key] = merge_and_sort(old, hash[sub_key])
+ cf(column_family)[key][sub_key] = merge_and_sort(old, validated_column_value_hash)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.