Open HarasimowiczKamil opened 4 years ago
Have similar error - with Repository->findOneByField (createQueryBuilder) returning the values from DB.
Cannot assign DateTime to property App\Entity\Post::$createdAt of type ?DateTimeImmutable
Have to make field to be DateTime in order to work normally with entity. :( Really unexpected behavior, considering that it DateTimeImmutable was generated by make:entity so should work by default.
@greg0ire old issue but still exist. I run into the same problem today. Can you take a look at it, please?
@greg0ire old issue but still exist. I run into the same problem today. Can you take a look at it, please?
try
#[ORM\Column(name: 'created_at', type: 'datetime_immutable' .....
@gimler can you reproduce the issue with a unit test?
Bug Report
Summary
Entity with "date_immutable" field returned from database has DateTime instead of DateTimeImmutable. If I change the annotation to "datetime_immutable" it works fine. I use Mysql engine if it matters.
Current behavior
How to reproduce
this throw exception:
Expected behavior
The expected behavior is that it would be a DateTimeImmutable object :smile: