From 1d40c85c3c35895d95af453479739c057ef21e11 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Thu, 6 Feb 2014 14:26:06 +0100 Subject: [PATCH] Right owning side column selection --- lib/Doctrine/ORM/Persisters/ManyToManyPersister.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php index 01c91a57e..a032982da 100644 --- a/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php @@ -349,9 +349,11 @@ class ManyToManyPersister extends AbstractCollectionPersister $associationSourceClass = $this->em->getClassMetadata($mapping['targetEntity']); $mapping = $associationSourceClass->associationMappings[$mapping['mappedBy']]; $joinColumns = $mapping['joinTable']['joinColumns']; + $relationMode = 'relationToTargetKeyColumns'; } else { $joinColumns = $mapping['joinTable']['inverseJoinColumns']; $associationSourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); + $relationMode = 'relationToSourceKeyColumns'; } $quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $associationSourceClass, $this->platform). ' t'; @@ -375,13 +377,11 @@ class ManyToManyPersister extends AbstractCollectionPersister } foreach ($mapping['joinTableColumns'] as $joinTableColumn) { - - - if (isset($mapping['relationToTargetKeyColumns'][$joinTableColumn])) { + if (isset($mapping[$relationMode][$joinTableColumn])) { $whereClauses[] = 't.' . $joinTableColumn . ' = ?'; $params[] = $targetEntity->containsForeignIdentifier - ? $id[$targetEntity->getFieldForColumn($mapping['relationToTargetKeyColumns'][$joinTableColumn])] - : $id[$targetEntity->fieldNames[$mapping['relationToTargetKeyColumns'][$joinTableColumn]]]; + ? $id[$targetEntity->getFieldForColumn($mapping[$relationMode][$joinTableColumn])] + : $id[$targetEntity->fieldNames[$mapping[$relationMode][$joinTableColumn]]]; } elseif (!$joinNeeded) { $whereClauses[] = 't.' . $joinTableColumn . ' = ?'; $params[] = $key;