-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
Feature Request
| Q | A |
|---|---|
| New Feature | yes |
| RFC | no |
| BC Break | no |
Summary
We found out that if the metadata field type differs from the entity property type Doctrine marks it as "to be updated" right after it being loaded from the database and hydrated, even if no real change happened to the entity. If there's a flush an update is performed for every entity marked as "to be updated", as it should happen.
For example if this is the metadata (Xml in this case)
MyEntity.xml:
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="MyEntity" table="my_table">
<id name="id" .../>
<field name="a" type="boolean" column="a_column" nullable="false"/>
</entity>
</doctrine-mapping>MyEntity.php:
class MyEntity
{
public function __construct(private int $a)
{
}
}This code updates to the database
/** @var EntityManagerInterface $em */
$myEntity = $em->getRepository(MyEntity::class)->find($myEntityId);
$em->flush();Please note that $a is int in MyEntity.php and boolean in MyEntity.xml
It would be great to have some strictness when setting the Entity value during Hydration or some field type validation in Doctrine\ORM\Tools\SchemaValidator.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels