Navigation Menu

Skip to content

Commit

Permalink
items#at handles nil range_key properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthakumaran committed May 11, 2012
1 parent 4c9c3c3 commit 80bfbd8
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/dynamoid/adapter/aws_sdk.rb
Expand Up @@ -82,11 +82,7 @@ def create_table(table_name, key = :id, options = {})
def delete_item(table_name, key, options = {})
range_key = options.delete(:range_key)
table = get_table(table_name)
result = if table.composite_key?
table.items.at(key, range_key)
else
table.items[key]
end
result = table.items.at(key, range_key)
result.delete unless result.attributes.to_h.empty?
true
end
Expand Down Expand Up @@ -119,11 +115,8 @@ def get_item(table_name, key, options = {})
range_key = options.delete(:range_key)
table = get_table(table_name)

result = if table.composite_key?
table.items.at(key, range_key)
else
table.items[key]
end.attributes.to_h(options)
result = table.items.at(key, range_key).attributes.to_h(options)

if result.empty?
nil
else
Expand Down

0 comments on commit 80bfbd8

Please sign in to comment.