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

Marshall ruby Symbols as Strings for attribute values #788

Merged
merged 1 commit into from
Jul 22, 2015

Conversation

wal
Copy link
Contributor

@wal wal commented Apr 22, 2015

Allow ruby Symbols as attribute values, converting them to string representation within the AWS::DynamoDB::AttributeValue::Marshaller

DynamoDB does not have a native Symbol type and so these values are un-marshalled as Strings. Is this acceptable ?

This issue manifests itself if you attempt to save a ruby hash containing symbols as values .. e.g

dynamo_client.put_item(table_name: dynamodb_table_name, item: {hash: 'my-hash', value: :symbol_value})

will throw the error

unsupported type, expected Hash, Array, Set, String, Numeric, IO, true, false, or nil, got Symbol

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling dbd3b72 on wal:symbols_as_strings_attribute_value into * on aws:master*.

@trevorrowe
Copy link
Member

I'm not against exploring this. When this was implemented initially, I purposefully chose to not support types that DynamoDB did not explicitly support. For example, DynamoDB does not have a native date or time attribute value. If I had made a customization to marshal ruby Time objects to a string value under a certain format then I would not be able to migrate to the new DynamoDB time attribute value without forcing users to migrate data.

Another consideration is that you will not be able to round-trip a hash with symbolized values and get back an equivalent hash. The values will have been stringified. This is probably okay, but it might surprise some users.

Generally, I think that Symbol is safe from having DynamoDB implement a native attribute value type.

Thoughts?

@trevorrowe
Copy link
Member

Ping. Any comments?

@trevorrowe
Copy link
Member

Sorry for sitting on this for so long. I've decided to merge this in. I don't see any possible path that DynamoDB could add a type that would need to map directly to a Ruby Symbol, leaving this open for string values. The SDK will however never attempt to symbolize strings on the way back out. This is for connivence, on setting values as they will not round-trip as symbols.

Thanks for the contribution.

trevorrowe added a commit that referenced this pull request Jul 22, 2015
Marshall ruby Symbols as Strings for attribute values
@trevorrowe trevorrowe merged commit c4fa8b6 into aws:master Jul 22, 2015
@wal
Copy link
Contributor Author

wal commented Jul 22, 2015

Thanks @trevorrowe

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 this pull request may close these issues.

3 participants