[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 response[name] = @value.to_f
when 'Name' when 'Name'
@attribute = @value @attribute = @value
response['Attributes'][@attribute] = [] response['Attributes'][@attribute] = [] unless response['Attributes'][@attribute].is_a?(Array)
when 'RequestId' when 'RequestId'
response[name] = @value response[name] = @value
when 'Value' when 'Value'

View File

@ -24,7 +24,7 @@ module Fog
response['Items'][@item_name] = {} response['Items'][@item_name] = {}
else else
@attribute_name = @value @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 end
when 'NextToken', 'RequestId' when 'NextToken', 'RequestId'
response[name] = @value response[name] = @value

View File

@ -19,6 +19,13 @@ describe 'SimpleDB.get_attributes' do
end end
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 it 'should have attributes for foo after put_attributes' do
AWS[:sdb].put_attributes(@domain_name, 'foo', { :bar => :baz }) AWS[:sdb].put_attributes(@domain_name, 'foo', { :bar => :baz })
eventually do eventually do

View File

@ -3,7 +3,22 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'SimpleDB.select' do describe 'SimpleDB.select' do
describe 'success' 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 end