diff --git a/aws-sdk-core/lib/aws-sdk-core/dynamodb/attribute_value.rb b/aws-sdk-core/lib/aws-sdk-core/dynamodb/attribute_value.rb index 9770496a086..b42ee78bc06 100644 --- a/aws-sdk-core/lib/aws-sdk-core/dynamodb/attribute_value.rb +++ b/aws-sdk-core/lib/aws-sdk-core/dynamodb/attribute_value.rb @@ -33,6 +33,7 @@ def format(obj) list[:l] << format(value) end when String then { s: obj } + when Symbol then { s: obj.to_s } when Numeric then { n: obj.to_s } when StringIO, IO then { b: obj } when Set then format_set(obj) @@ -49,7 +50,7 @@ def format(obj) def format_set(set) case set.first - when String then { ss: set.map(&:to_s) } + when String, Symbol then { ss: set.map(&:to_s) } when Numeric then { ns: set.map(&:to_s) } when StringIO, IO then { bs: set.to_a } else diff --git a/aws-sdk-core/spec/aws/dynamodb/attribute_value_spec.rb b/aws-sdk-core/spec/aws/dynamodb/attribute_value_spec.rb index cb9384b0794..0e4929ef921 100644 --- a/aws-sdk-core/spec/aws/dynamodb/attribute_value_spec.rb +++ b/aws-sdk-core/spec/aws/dynamodb/attribute_value_spec.rb @@ -37,6 +37,11 @@ module DynamoDB expect(formatted).to eq(ss: %w(abc mno)) end + it 'converts symbol sets to :ss (string set)' do + formatted = value.marshal(Set.new([:abc, :mno])) + expect(formatted).to eq(ss: %w(abc mno)) + end + it 'converts numeric sets to :ns (number set)' do formatted = value.marshal(Set.new([123, 456])) expect(formatted).to eq(ns: %w(123 456)) @@ -59,6 +64,10 @@ module DynamoDB expect(value.marshal('abc')).to eq(s: 'abc') end + it 'converts symbol to :s' do + expect(value.marshal(:abc)).to eq(s: 'abc') + end + it 'converts booleans :bool' do # supports both true and false expect(value.marshal(true)).to eq(bool: true)