Skip to content
Browse files

Revert "removing empty checks so that [] can be persisted"

This reverts commit 7e27378.
  • Loading branch information...
1 parent 75bd7e2 commit 51d91e1d5035ddd774f45f874cb9f9ef24bac7b2 @jasondew committed Jun 25, 2012
Showing with 4 additions and 4 deletions.
  1. +1 −1 lib/dynamoid/adapter/aws_sdk.rb
  2. +1 −1 lib/dynamoid/adapter/local.rb
  3. +2 −2 spec/dynamoid/indexes/index_spec.rb
View
2 lib/dynamoid/adapter/aws_sdk.rb
@@ -152,7 +152,7 @@ def list_tables
# @since 0.2.0
def put_item(table_name, object)
table = get_table(table_name)
- table.items.create(object.delete_if{|k, v| v.nil? })
+ table.items.create(object.delete_if{|k, v| v.nil? || (v.respond_to?(:empty?) && v.empty?)})
end
# Query the DynamoDB table. This employs DynamoDB's indexes so is generally faster than scanning, but is
View
2 lib/dynamoid/adapter/local.rb
@@ -118,7 +118,7 @@ def list_tables
def put_item(table_name, object)
table = data[table_name]
table[:data][object[table[:hash_key]]]
- table[:data]["#{object[table[:hash_key]]}.#{object[table[:range_key]]}"] = object.delete_if{|k, v| v.nil? }
+ table[:data]["#{object[table[:hash_key]]}.#{object[table[:range_key]]}"] = object.delete_if{|k, v| v.nil? || (v.respond_to?(:empty?) && v.empty?)}
rescue
raise data.inspect
end
View
4 spec/dynamoid/indexes/index_spec.rb
@@ -87,7 +87,7 @@
@index.save(@user)
@index.delete(@user)
- Dynamoid::Adapter.read("dynamoid_tests_index_user_names", 'Josh')[:ids].should be_empty
+ Dynamoid::Adapter.read("dynamoid_tests_index_user_names", 'Josh')[:ids].should be_nil
end
it 'updates an object by removing it from its previous index and adding it to its new one' do
@@ -99,7 +99,7 @@
@user.update_attributes(:name => 'Justin')
- Dynamoid::Adapter.read("dynamoid_tests_index_user_names", 'Josh')[:ids].should be_empty
+ Dynamoid::Adapter.read("dynamoid_tests_index_user_names", 'Josh')[:ids].should be_nil
Dynamoid::Adapter.read("dynamoid_tests_index_user_names", 'Justin')[:ids].should == Set['test123']
end

0 comments on commit 51d91e1

Please sign in to comment.
Something went wrong with that request. Please try again.