Bug #29982

Wrong table structure for multiple ManyToOne relations

Added by Alexander Stehlik almost 4 years ago. Updated almost 4 years ago.

Status:Resolved Start date:2011-09-18
Priority:Should have Due date:
Assigned To:Karsten Dambekalns % Done:

100%

Category:Persistence
Target version:TYPO3 Flow Base Distribution - 1.0.0
PHP Version: Complexity:
Has patch: Affected Flow version:

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

duplicates TYPO3.Flow - Bug #30223: Column names for association properties are generated wrong Resolved 2011-09-23

History

#1 Updated by Karsten Dambekalns almost 4 years ago

  • Project changed from Doctrine 2 to TYPO3.Flow

#2 Updated by Karsten Dambekalns almost 4 years ago

  • Category set to Persistence
  • Status changed from New to Resolved
  • Assigned To set to Karsten Dambekalns
  • Target version set to 1.0.0
  • % Done changed from 0 to 100

Resolved with #30223.

Also available in: Atom PDF