mirror of
https://github.com/doctrine/orm.git
synced 2026-04-29 09:23:20 +02:00
Using DiscriminatorMap - a child node uses the parents object for an ID field #6322
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 @rlweb on GitHub (Oct 1, 2019).
Originally assigned to: @lcobucci on GitHub.
Bug Report
Summary
When using the DiscriminatorMap on a child node of an object, it gives the parent object to the ID property of the ManyToOne object.
As shown above is a Note object which contains a Person ManyToOne entity
Current behavior
The ID of the child object (via the discriminator map) is the parent object.
How to reproduce
See https://github.com/rlweb/orm/commit/54fc7414a2593eafdfb1abe21662444e72755b10 for an example of my issue which gives the following:

Expected behavior
The ID to be correctly set as an integer.
@Ocramius commented on GitHub (Oct 1, 2019):
I'm not sure what's being asked: it is not possible to override property types in a table inheritance, is that what you are trying to do?
@rlweb commented on GitHub (Oct 1, 2019):
Hi @Ocramius, I'm not trying to override property types, rather I would like to use class table inheritance to return the type of Person who updated the note.
So like below we have 2 types of users: contact and staff. We would like to link notes to the Person entity.
It seems odd that doctrine cannot pass back the correct ID of the person entity but can link the entities correctly which is the bug shown in the unit test :)
@Ocramius commented on GitHub (Oct 1, 2019):
Ah, I totally missed the test.
I think this is a bug caused by silly proxy optimisations.
Do you have a chance to check if this also applies to
master?@rlweb commented on GitHub (Oct 1, 2019):
It works in master! Thanks @Ocramius :) Any idea on the progress of v3 and would it be released in the next year?
@lcobucci commented on GitHub (Oct 2, 2019):
@rlweb there's an error on your mapping, which is making the entities to be hydrated in the wrong way. You're telling the ORM that
lastUpdatedByis inversedByPerson.id, which isn't correct sincePersonis clueless aboutNote.Here's the fix:
@lcobucci commented on GitHub (Oct 2, 2019):
Closing as
invalidas per my comment 👍@lcobucci commented on GitHub (Oct 2, 2019):
@rlweb no idea on the release date, yet