Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Commit

Permalink
Query serializer no longer sends nil as empty value.
Browse files Browse the repository at this point in the history
Fixes #133
  • Loading branch information
trevorrowe committed Oct 16, 2014
1 parent f946c11 commit 8611c8a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Next Release (TBD)

* Feature - Waiters - Added waiters for Amazon EC2 image availability.

* Issue - Resolved an issue with the query serializer sending `nil`
values. See #133.

2.0.2 (2014-10-08)
------------------

Expand Down
6 changes: 4 additions & 2 deletions aws-sdk-core/lib/aws-sdk-core/query/ec2_param_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ def apply(shape, params)
# @param [String, nil] prefix
def structure(structure, values, prefix)
values.each do |name, value|
member_shape = structure.member(name)
format(member_shape, value, prefix + query_name(member_shape))
unless value.nil?
member_shape = structure.member(name)
format(member_shape, value, prefix + query_name(member_shape))
end
end
end

Expand Down
6 changes: 4 additions & 2 deletions aws-sdk-core/lib/aws-sdk-core/query/param_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ def apply(shape, params)
# @param [String, nil] prefix
def structure(structure, values, prefix)
values.each do |name, value|
member_shape = structure.member(name)
format(member_shape, value, prefix + query_name(member_shape))
unless value.nil?
member_shape = structure.member(name)
format(member_shape, value, prefix + query_name(member_shape))
end
end
end

Expand Down
9 changes: 9 additions & 0 deletions aws-sdk-core/spec/aws/query/param_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ def query_params(params = {})
])
end

it 'does not serialize nil values' do
members['Name'] = { 'type' => 'string' }
members['Nickname'] = { 'type' => 'string' }
params = { name: 'John', nickname: nil }
expect(query_params(params)).to eq([
['Name', 'John'],
])
end

end

describe 'flattened lists' do
Expand Down

0 comments on commit 8611c8a

Please sign in to comment.