Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The '#find' command doesn't properly populate database_attribute_name if symbolized #103

Closed
awood45 opened this issue May 27, 2020 · 1 comment · Fixed by #104
Closed

Comments

@awood45
Copy link
Member

awood45 commented May 27, 2020

To reproduce, consider the following class:

class FindTestTable
  include Aws::Record

  string_attr :hash, hash_key: true, database_attribute_name: :hk
  string_attr :range, range_key: true, database_attribute_name: :rk
end

This class will work for creating new items and saving them, but if you run the following, you'll have a problem:

item = FindTestTable.find(hash: 'validh', range: 'validr')
item.to_h # will have nil values for both keys

This works correctly if you stringify the values, as is documented:

class FindTestTable
  include Aws::Record

  string_attr :hash, hash_key: true, database_attribute_name: 'hk'
  string_attr :range, range_key: true, database_attribute_name: 'rk'
end

I think this should be enhanced to properly read from databases when you use symbols for the database_attribute_name, it was likely an oversight on my part that it didn't to begin with. I also think this is likely a decent first issue for someone looking to get familiar with the deserialization logic.

@mullermp
Copy link
Contributor

Thanks Alex. Will take a look at this when we have bandwidth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants