1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[simpleDB] Only the last value of a multi-value attribute was being returned by get_attributes and select. Patch and specs to cover.

This commit is contained in:
Jeremy Deininger 2010-07-13 08:18:02 +08:00 committed by Wesley Beary
parent 7b12b736f4
commit 9dd4e9877c
4 changed files with 26 additions and 4 deletions

View file

@ -20,7 +20,7 @@ module Fog
response[name] = @value.to_f
when 'Name'
@attribute = @value
response['Attributes'][@attribute] = []
response['Attributes'][@attribute] = [] unless response['Attributes'][@attribute].is_a?(Array)
when 'RequestId'
response[name] = @value
when 'Value'

View file

@ -24,7 +24,7 @@ module Fog
response['Items'][@item_name] = {}
else
@attribute_name = @value
response['Items'][@item_name][@attribute_name] = []
response['Items'][@item_name][@attribute_name] = [] unless response['Items'][@item_name][@attribute_name].is_a?(Array)
end
when 'NextToken', 'RequestId'
response[name] = @value

View file

@ -19,6 +19,13 @@ describe 'SimpleDB.get_attributes' do
end
end
it 'should return multi-value attributes from get_attributes' do
AWS[:sdb].put_attributes(@domain_name, 'buzz', { "attr" => "foo" })
AWS[:sdb].put_attributes(@domain_name, 'buzz', { "attr" => "foo2" })
actual = AWS[:sdb].get_attributes(@domain_name, 'buzz')
actual.body["Attributes"]["attr"].should == ['foo', 'foo2']
end
it 'should have attributes for foo after put_attributes' do
AWS[:sdb].put_attributes(@domain_name, 'foo', { :bar => :baz })
eventually do

View file

@ -3,7 +3,22 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'SimpleDB.select' do
describe 'success' do
it "should have some specs"
before(:each) do
@domain_name = "fog_domain_#{Time.now.to_i}"
AWS[:sdb].create_domain(@domain_name)
end
after(:each) do
AWS[:sdb].delete_domain(@domain_name)
end
it 'should return multi-value attributes when present' do
@item = "someitem_fog_domain_#{Time.now.to_i}"
AWS[:sdb].put_attributes(@domain_name, @item, { "attr" => "foo" })
AWS[:sdb].put_attributes(@domain_name, @item, { "attr" => "foo2" })
actual = AWS[:sdb].select("select * from #{@domain_name}")
actual.body['Items'][@item]["attr"].should == ['foo','foo2']
end
end
end
end