mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1444: Be able to set a value also used in relation #1812
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 @doctrinebot on GitHub (Oct 21, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user rapotor:
I am using a string field for data and for an optional relation too.
I am not using a ID because the second entity is from a third party application.
I used two variables in my entity mapping to the same field.
The getter is working fine.
The problem occurs when I create a new entity and would like to persist it.
As the field is used twice, the value of the second variable is erasing the first value.
At the line 525 of Doctrine\ORM\Persisters\BasicEntityPersister , I added the following test to update a null value only if there is no fieldName existing.
...
foreach ($assoc['sourceToTargetKeyColumns'] as $sourceColumn => $targetColumn) {
if ($newVal === null) {
if(!isset($this->_class->fieldNames[$sourceColumn]) || in_array($sourceColumn, $this->_class->identifier)) {
$result[$owningTable][$sourceColumn] = null;
}
} else if ($targetClass->containsForeignIdentifier) {
...
(!isset($this->_class->fieldNames[$sourceColumn]) : Test if there is no existing fieldName
in_array($sourceColumn, $this->_class->identifier)) : avoid skipping identifier definition because ID is listed in fieldNames!
What do you think about that?
Thanks.
@beberlei commented on GitHub (Feb 16, 2020):
Not supported use case to re-use the same column for multiple things.