Skip to content

Commit

Permalink
removing empty checks so that [] can be persisted
Browse files Browse the repository at this point in the history
  • Loading branch information
jasondew committed Jun 25, 2012
1 parent 983b621 commit 7e27378
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/dynamoid/adapter/aws_sdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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? || (v.respond_to?(:empty?) && v.empty?)})
table.items.create(object.delete_if{|k, v| v.nil? })
end

# Query the DynamoDB table. This employs DynamoDB's indexes so is generally faster than scanning, but is
Expand Down
2 changes: 1 addition & 1 deletion lib/dynamoid/adapter/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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? || (v.respond_to?(:empty?) && v.empty?)}
table[:data]["#{object[table[:hash_key]]}.#{object[table[:range_key]]}"] = object.delete_if{|k, v| v.nil? }
rescue
raise data.inspect
end
Expand Down
4 changes: 2 additions & 2 deletions spec/dynamoid/indexes/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
@index.save(@user)
@index.delete(@user)

Dynamoid::Adapter.read("dynamoid_tests_index_user_names", 'Josh')[:ids].should be_nil
Dynamoid::Adapter.read("dynamoid_tests_index_user_names", 'Josh')[:ids].should be_empty
end

it 'updates an object by removing it from its previous index and adding it to its new one' do
Expand All @@ -99,7 +99,7 @@

@user.update_attributes(:name => 'Justin')

Dynamoid::Adapter.read("dynamoid_tests_index_user_names", 'Josh')[:ids].should be_nil
Dynamoid::Adapter.read("dynamoid_tests_index_user_names", 'Josh')[:ids].should be_empty
Dynamoid::Adapter.read("dynamoid_tests_index_user_names", 'Justin')[:ids].should == Set['test123']
end

Expand Down

0 comments on commit 7e27378

Please sign in to comment.