laravel-dynamodb
laravel-dynamodb copied to clipboard
$cast
Double check plz
$casts don't work the way the user expected it to in #166 $casts only are suppose to apply while accessing a value on the model, not before storing them in the database. See this entry and example in the doc.
As there is nothing to change i suggest closing this issue
No, this is there for me to ensure $cast is supported. It isn't with the aim to cater for that issue scenario. The user mentioned $cast and it made me realize that I have not tested this feature.
sure, got that but as $casts is non database related and is handled in Concerns\HasAttributes and the DynamoDbModel extends the Eloquent Model which uses the HasAttributes Concern which only acts on the models attributes when accessed directly and you don't overwrite any of this, I thought you might not want to wast your time chasing ghosts. It's Eloquent default behavior.
Keep up the great work <3
Haha thanks for that. I had concern about letting it roam free without proper testing. I just need to double check if there are any formats that would not work, then I can document it perhaps. Thanks for helping me groom thru the backlog. Appreciate it truly.
Is there a better way of doing what I've implemented in this commit, and if you wouldn't mind, is there any edge cases I may have missed? (constraints?) cbf6bd6c27211750f37324d4a20d6049011b2f2c
My use case is storing an unsigned 64 bit integer to the database as a Number, but as PHP does not support unsigned integers, I have to store this as a string when referencing to it. So, I use this code (which is very hacky imo) to cast before making the DynamoDB queries. I also need this to store unix timestamps as Numbers, which the library does not seem to do.
Many thanks.
On the timestamp problem, how are you generating the timestamp? We use $model->createdAt = now()->timestamp and it stores it as a Number.
I'm using $dateFormat = 'U' and the serializeDate function in the model then let Laravel handle the attributes for me. No need to set them manually. I guess it just serializes as a string like that?
Ahh that’s annoying. Weird that’s how Laravel handles that, I guess dates are normally strings if not an object. I wonder how deep that goes, possibly it’s changeable.