Open ychaker opened 4 years ago
Could you please provide a code snippet to reproduce the issue?
The issue is DynamoDB doesn't support Date/Time/DateTime type internally so such columns are stored either as number of seconds or as a string. Looks like an attribute value somehow isn't type casted by Dynamoid.
Something like this:
record.update do |r|
r.set data: data
r.set synced_at: DateTime.current
end
When getting a record from DynamoDB there are no issues casting a DynamoDB string to ruby datetime, however when attempting to save a datetime object, it isn't casted to string to persist on DynamoDB.
But shouldn't datetime values be auto-casted if the declared field attribute is string?
I see. Yes, it's definitely a bug in the #update
/#update!
methods.
thank you @jmonsanto for providing the example, I dropped the ball on that when I saw the notification and then completely forgot about it, sorry!
howdy! First of all I'd like to thank everyone for their effort on this gem, I truly appreciate all of you work.
I'm new to the gem and DynamoDB overall, so excuse my noob question.
According to the README (and rspec files), I was under the impression that we could pass a
DateTime
object to a field that is configured to be of type:datetime
, however when trying to set a field to a value like this:I get an error saying
unsupported type, expected Hash, Array, Set, String, Numeric, IO, true, false, or nil, got DateTime
you can see the stack trace here:
However, if I change the value to be:
while keeping the type as
:datetime
everything works. I feel it's odd that I'd have to pass aString
, which if I'm not mistaken, then gets converted to aDateTime
by the type caster, and then to a number.Am I doing something wrong?