Skip to content

Commit

Permalink
Merge 9939e55 into d6dd6a7
Browse files Browse the repository at this point in the history
  • Loading branch information
alextwoods committed May 27, 2020
2 parents d6dd6a7 + 9939e55 commit 0e458b3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
@@ -1,3 +1,3 @@
[submodule "tasks/release"]
path = tasks/release
url = git@github.com:aws/aws-sdk-ruby-release-tools.git
url = https://github.com/aws/aws-sdk-ruby-release-tools.git
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
Unreleased Changes
------------------

* Issue - Allow symbols for database_attribute_name

2.4.0 (2019-07-16)
------------------

Expand Down
2 changes: 1 addition & 1 deletion lib/aws-record/record/attribute.rb
Expand Up @@ -48,7 +48,7 @@ class Attribute
# item is nil or not set at persistence time.
def initialize(name, options = {})
@name = name
@database_name = options[:database_attribute_name] || name.to_s
@database_name = (options[:database_attribute_name] || name).to_s
@dynamodb_type = options[:dynamodb_type]
@marshaler = options[:marshaler] || DefaultMarshaler
@persist_nil = options[:persist_nil]
Expand Down
6 changes: 6 additions & 0 deletions spec/aws-record/record/attribute_spec.rb
Expand Up @@ -24,6 +24,12 @@ module Record
expect(a.database_name).to eq("bar")
end

it 'can accept a symbol as a custom DB name' do
a = Attribute.new(:foo, database_attribute_name: :bar)
expect(a.name).to eq(:foo)
expect(a.database_name).to eq("bar")
end

it 'uses the attribute name by default for the DB name' do
a = Attribute.new(:foo)
expect(a.name).to eq(:foo)
Expand Down

0 comments on commit 0e458b3

Please sign in to comment.