Bug #29982

Wrong table structure for multiple ManyToOne relations

Added by Alexander Stehlik about 10 years ago. Updated about 10 years ago.

Status:
Resolved
Priority:
Should have
Category:
Persistence
Start date:
2011-09-18
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

Description

I stumbled upon an issue when using two @ManyToOne properties in one model, that both point to the same related model (in my case it was a transaction that had an "account" and a "sourceOrTargetAccount" property. Both had the following annotation:

/**
 * @var \My\Namespace\MyPackage\Domain\Model\Account
 * @ManyToOne(cascade={"persist"})
 */

After calling doctrine:update there was only one column in the transaction table called mypackage_account that referenced values in the account table. Additionally I realised that the values of the sourceOrTargetAccount property were stored in this column. The value of the account property was not stored anywhere.

To fix this, I used the @JoinColumn annotation to specify the column:

@JoinColumn(name="source_or_target_account", referencedColumnName="flow3_persistence_identifier")

Maybe this behaviour is expected? If so this probably should be added to the docs.


Related issues

Is duplicate of TYPO3.Flow - Bug #30223: Column names for association properties are generated wrongResolvedKarsten Dambekalns2011-09-23

Actions

Also available in: Atom PDF