mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Custom DBAL Type Ignored During Hydration: TypeError When Using Collection in Entity #7453
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pizgariu on GitHub (Dec 24, 2024).
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, theconvertToPHPValuemethod of the custom type is ignored during hydration, resulting in aTypeError. Doctrine tries to assign anarrayto 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
arrayto 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
Collectioninstance 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