Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[DDC-1895] Fix fetch relation by id of association field #386

Merged
merged 1 commit into from

4 participants

@travisbot

This pull request passes (merged acde0997 into 417b6b0).

@Burgov

@guilhermeblanco your comment seems to have disappeared, but I've applied your suggested change

Can you change this piece of code to a switch?
We try to apply some rules that we are trying to get rid of all "else"s.

@travisbot

This pull request passes (merged 5dc999a into 417b6b0).

@guilhermeblanco guilhermeblanco merged commit ab851ab into from
@beberlei
Owner

This was merged into 2.1.x? :(

@beberlei
Owner

@Burgov can you open against master again?

@Burgov Burgov referenced this pull request
Merged

fixed DDC-1895 #389

@Burgov

@beberlei I opened it on 2.1 because I thought it would be merge into 2.3 later on. I've created a new PR for 2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 3, 2012
  1. @Burgov

    fixed DDC-1895

    Burgov authored
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
View
14 lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
@@ -349,7 +349,19 @@ public function update($entity)
$targetMapping = $this->_em->getClassMetadata($this->_class->associationMappings[$idField]['targetEntity']);
$where[] = $this->_class->associationMappings[$idField]['joinColumns'][0]['name'];
$params[] = $id[$idField];
- $types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];
+
+ switch (true) {
+ case (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])):
+ $types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];
+ break;
+
+ case (isset($targetMapping->associationMappings[$targetMapping->identifier[0]])):
+ $types[] = $targetMapping->associationMappings[$targetMapping->identifier[0]]['type'];
+ break;
+
+ default:
+ throw ORMException::unrecognizedField($targetMapping->identifier[0]);
+ }
} else {
$where[] = $this->_class->getQuotedColumnName($idField, $this->_platform);
$params[] = $id[$idField];
Something went wrong with that request. Please try again.