You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a custom DBAL type that converts JSON data into a Doctrine\Common\Collections\Collection (e.g., ArrayCollection), Doctrine fails to properly handle hydration. Despite the type being registered and used in the entity, the convertToPHPValue method of the custom type is ignored during hydration, resulting in a TypeError. Doctrine tries to assign an array to a property typed as Collection, which leads to the error.
Current behavior
Doctrine does not use the custom DBAL type during hydration. Instead, it attempts to assign a raw array to the entity property, ignoring the expected conversion to Collection.
Expected behavior
Doctrine should respect the custom DBAL type and correctly convert the JSON data into the expected Collection instance during hydration.
Bug Report
Summary
When using a custom DBAL type that converts JSON data into a
Doctrine\Common\Collections\Collection
(e.g.,ArrayCollection
), Doctrine fails to properly handle hydration. Despite the type being registered and used in the entity, theconvertToPHPValue
method of the custom type is ignored during hydration, resulting in aTypeError
. Doctrine tries to assign anarray
to a property typed asCollection
, which leads to the error.Current behavior
Doctrine does not use the custom DBAL type during hydration. Instead, it attempts to assign a raw
array
to the entity property, ignoring the expected conversion toCollection
.Expected behavior
Doctrine should respect the custom DBAL type and correctly convert the JSON data into the expected
Collection
instance during hydration.How to reproduce
Provide a custom DBAL type:
Register the type:
Define an entity:
When trying to hydrate this entity, you get the following error:
Stacktrace
Click to expand stacktrace
The text was updated successfully, but these errors were encountered: