DDC-2767: ID property of MayToOne association has wrong type #3460

Open
opened 2026-01-22 14:20:19 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 30, 2013).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user flack:

I'm seeing the following behaviour in some Doctrine code I'm writing:

$entity = array_pop($qb->getQuery()->getResult());
echo gettype($entity->getId()) . ' ' . $entity->getId();
// prints: integer 123

$association = $entity->getAssociation(); // unidirectional ManyToOne link to some other entity
echo gettype($association->getId()) . ' ' . $association->getId();
// prints: string 345

When I load the associated entity directly (via find() f.x.), it's ID has the integer type as expected, and the database structure looks correct, too.

I'm not entirely sure if this is a problem in my code or some issue in QueryBuilder or some other Doctrine component, but if someone could point me into the right direction, that would really be helpful.

I guess normally the type of the ID is not so important because you're not supposed to access it directly anyways, but I need to provide backward compatibility for a lot of code written against a different ORM API that provided exactly this behaviour.

Originally created by @doctrinebot on GitHub (Oct 30, 2013). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user flack: I'm seeing the following behaviour in some Doctrine code I'm writing: ``` $entity = array_pop($qb->getQuery()->getResult()); echo gettype($entity->getId()) . ' ' . $entity->getId(); // prints: integer 123 $association = $entity->getAssociation(); // unidirectional ManyToOne link to some other entity echo gettype($association->getId()) . ' ' . $association->getId(); // prints: string 345 ``` When I load the associated entity directly (via find() f.x.), it's ID has the integer type as expected, and the database structure looks correct, too. I'm not entirely sure if this is a problem in my code or some issue in QueryBuilder or some other Doctrine component, but if someone could point me into the right direction, that would really be helpful. I guess normally the type of the ID is not so important because you're not supposed to access it directly anyways, but I need to provide backward compatibility for a lot of code written against a different ORM API that provided exactly this behaviour.
admin added the Bug label 2026-01-22 14:20:19 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 7, 2013):

Comment created by flack:

After some research, the problem sounds kind of similar to

http://www.doctrine-project.org/jira/browse/DDC-2494

only that in my case, it's not a custom type, but a builtin one that is not working. But AFAICT, in both cases it's getting the ID from a proxy that is problematic

@doctrinebot commented on GitHub (Nov 7, 2013): Comment created by flack: After some research, the problem sounds kind of similar to http://www.doctrine-project.org/jira/browse/[DDC-2494](http://www.doctrine-project.org/jira/browse/DDC-2494) only that in my case, it's not a custom type, but a builtin one that is not working. But AFAICT, in both cases it's getting the ID from a proxy that is problematic
Author
Owner

@doctrinebot commented on GitHub (Jul 14, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1073] was closed:
https://github.com/doctrine/doctrine2/pull/1073

@doctrinebot commented on GitHub (Jul 14, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-1073] was closed: https://github.com/doctrine/doctrine2/pull/1073
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3460