laravel-event-sourcing icon indicating copy to clipboard operation
laravel-event-sourcing copied to clipboard

Event properties matching ShouldBeStored methods are not serialized correctly

Open ganyicz opened this issue 6 months ago • 1 comments

This is due to how Symfony serializer works. When the serialized object (event) contains a method with the name of the attribute, return value of that method is preferred and the value of the attribute is ignored.

The simplest example of this is declaring a Carbon property named createdAt. When an event with this property is stored with a value different from now, the provided value is ignored and instead the event is saved in the database with the current time being the value of this property (which is the return value of the createdAt method on ShouldBeStored)

ganyicz avatar Aug 14 '24 22:08 ganyicz