Skip to content

Commit

Permalink
Fix IO Handling in DynamoDB Sets
Browse files Browse the repository at this point in the history
The hash and array logic used the format method changed in the previous
diff, so those worked correctly from the outset. Sets, however, had
special logic which required a second change.
  • Loading branch information
awood45 committed Jun 3, 2015
1 parent b59e760 commit 2e23d35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion aws-sdk-core/lib/aws-sdk-core/dynamodb/attribute_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def format_set(set)
case set.first
when String then { ss: set.map(&:to_s) }
when Numeric then { ns: set.map(&:to_s) }
when StringIO, IO then { bs: set.map(&:read) }
when StringIO, IO then { bs: set.to_a }
else
msg = "set types only support String, Numeric, or IO objects"
raise ArgumentError, msg
Expand Down
7 changes: 4 additions & 3 deletions aws-sdk-core/spec/aws/dynamodb/attribute_value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module DynamoDB
])
end

it 'converts IO objects to :b (blob)' do
it 'converts IO objects to :b (binary)' do
io = StringIO.new('bar')
formatted = value.marshal(foo: io)
expect(formatted[:m]["foo"][:b].read).to eq('bar')
Expand All @@ -43,8 +43,9 @@ module DynamoDB
end

it 'converts binary sets to :bs (binary set)' do
formatted = value.marshal(Set.new([StringIO.new('data')]))
expect(formatted).to eq(bs: ['data'])
io_obj = StringIO.new('data')
formatted = value.marshal(Set.new([io_obj]))
expect(formatted).to eq(bs: [io_obj])
end

it 'converts numerics to :n (number)' do
Expand Down

0 comments on commit 2e23d35

Please sign in to comment.