Dynamoid
Dynamoid copied to clipboard
String max length
When you call write_attribute
here: https://github.com/Veraticus/Dynamoid/blob/master/lib/dynamoid/fields.rb#L73
You're checking the length of the string with size
when it should actually be bytesize
. Also, the length of things aren't constrained unless they're a primary or range key.
Relevant documentation:
- http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html
- http://ruby-doc.org/core-2.0.0/String.html#method-i-size
.size and .bytesize on a string are the same thing since a character is a byte and .size returns the number of characters.
Also, the size limit applies to the object as a whole. In fact you cannot store items greater than 400KB (so the limit should be raised to 400KB from 64KB which is the old limit). This check is somewhat pointless though since it doesn't check total item size, but is still somewhat useful as a sanity check.
The strings in DynamoDB are UTF-8 (it says in one of the links I put in the original post), which doesn't guarantee that one character is one byte in length. For more information, this is an excellent read: http://www.joelonsoftware.com/articles/Unicode.html.