DDC-3797: IDENTITY function does not hydrate custom types #4652

Open
opened 2026-01-22 14:46:50 +01:00 by admin · 1 comment
Owner

Originally created by @doctrinebot on GitHub (Jun 26, 2015).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user marcospassos:

The function IDENTITY does not hydrate customs types. I've a OrganizationId type, but when a execute the following DQL I got an error, because Doctrine tries to pass an integer as argument of my object constructor instead of an OrganizationId instance.

<mapped-superclass name="Campaign">
        <id name="id" column="id" type="campaign_id" />
        <id name="organization" column="organization_id" association-key="true" />
        <many-to-one field="organization" target-entity="Organization">
            <join-column name="organization_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE" />
        </many-to-one>
    </mapped-superclass>
SELECT NEW CampaignDTO(c.id, IDENTITY(c.organization), c.name) FROM Campaign c

Result:

Catchable Fatal Error: Argument 2 passed to Campaign::**construct() must be an instance of OrganizationId, integer given
Originally created by @doctrinebot on GitHub (Jun 26, 2015). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user marcospassos: The function IDENTITY does not hydrate customs types. I've a OrganizationId type, but when a execute the following DQL I got an error, because Doctrine tries to pass an integer as argument of my object constructor instead of an OrganizationId instance. ``` xml <mapped-superclass name="Campaign"> <id name="id" column="id" type="campaign_id" /> <id name="organization" column="organization_id" association-key="true" /> <many-to-one field="organization" target-entity="Organization"> <join-column name="organization_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE" /> </many-to-one> </mapped-superclass> ``` ``` sql SELECT NEW CampaignDTO(c.id, IDENTITY(c.organization), c.name) FROM Campaign c ``` Result: ``` Catchable Fatal Error: Argument 2 passed to Campaign::**construct() must be an instance of OrganizationId, integer given ```
admin added the Bug label 2026-01-22 14:46:50 +01:00
Author
Owner

@beberlei commented on GitHub (Feb 16, 2020):

This can now be fixed with TypedExpression support https://github.com/doctrine/orm/pull/7941

Identity should implement that interface and return the correct DBAL type of the column.

@beberlei commented on GitHub (Feb 16, 2020): This can now be fixed with `TypedExpression` support https://github.com/doctrine/orm/pull/7941 Identity should implement that interface and return the correct DBAL type of the column.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4652