1
0
mirror of synced 2025-01-30 03:51:43 +03:00

[2.0][DDC-51] Fixed.

This commit is contained in:
romanb 2009-10-15 17:07:37 +00:00
parent 5842411afe
commit 9200e17bc1
3 changed files with 10 additions and 11 deletions

View File

@ -106,13 +106,13 @@ class OneToManyMapping extends AssociationMapping
} }
/** /**
* Loads a one-to-many collection.
* *
* * @param $sourceEntity The entity that owns the collection.
* @param $sourceEntity * @param $targetCollection The collection to load/fill.
* @param $targetCollection * @param $em The EntityManager to use.
* @param $em * @param $joinColumnValues
* @param $joinColumnValues * @return void
* @return unknown_type
*/ */
public function load($sourceEntity, $targetCollection, $em, array $joinColumnValues = array()) public function load($sourceEntity, $targetCollection, $em, array $joinColumnValues = array())
{ {
@ -121,9 +121,9 @@ class OneToManyMapping extends AssociationMapping
$sourceClass = $em->getClassMetadata($this->sourceEntityName); $sourceClass = $em->getClassMetadata($this->sourceEntityName);
$owningAssoc = $em->getClassMetadata($this->targetEntityName)->associationMappings[$this->mappedByFieldName]; $owningAssoc = $em->getClassMetadata($this->targetEntityName)->associationMappings[$this->mappedByFieldName];
// TRICKY: since the association is specular source and target are flipped // TRICKY: since the association is specular source and target are flipped
foreach ($owningAssoc->getTargetToSourceKeyColumns() as $sourceKeyColumn => $targetKeyColumn) { foreach ($owningAssoc->targetToSourceKeyColumns as $sourceKeyColumn => $targetKeyColumn) {
// getting id // getting id
if (isset($sourceClass->reflFields[$sourceKeyColumn])) { if (isset($sourceClass->fieldNames[$sourceKeyColumn])) {
$conditions[$targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); $conditions[$targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity);
} else { } else {
$conditions[$targetKeyColumn] = $joinColumnValues[$sourceKeyColumn]; $conditions[$targetKeyColumn] = $joinColumnValues[$sourceKeyColumn];

View File

@ -201,7 +201,7 @@ class OneToOneMapping extends AssociationMapping
if ($this->isOwningSide) { if ($this->isOwningSide) {
foreach ($this->sourceToTargetKeyColumns as $sourceKeyColumn => $targetKeyColumn) { foreach ($this->sourceToTargetKeyColumns as $sourceKeyColumn => $targetKeyColumn) {
// getting customer_id // getting customer_id
if (isset($sourceClass->reflFields[$sourceKeyColumn])) { if (isset($sourceClass->fieldNames[$sourceKeyColumn])) {
$conditions[$targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); $conditions[$targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity);
} else { } else {
$conditions[$targetKeyColumn] = $joinColumnValues[$sourceKeyColumn]; $conditions[$targetKeyColumn] = $joinColumnValues[$sourceKeyColumn];
@ -220,7 +220,7 @@ class OneToOneMapping extends AssociationMapping
// TRICKY: since the association is specular source and target are flipped // TRICKY: since the association is specular source and target are flipped
foreach ($owningAssoc->targetToSourceKeyColumns as $sourceKeyColumn => $targetKeyColumn) { foreach ($owningAssoc->targetToSourceKeyColumns as $sourceKeyColumn => $targetKeyColumn) {
// getting id // getting id
if (isset($sourceClass->reflFields[$sourceKeyColumn])) { if (isset($sourceClass->fieldNames[$sourceKeyColumn])) {
$conditions[$targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); $conditions[$targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity);
} else { } else {
$conditions[$targetKeyColumn] = $joinColumnValues[$sourceKeyColumn]; $conditions[$targetKeyColumn] = $joinColumnValues[$sourceKeyColumn];

View File

@ -87,7 +87,6 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public function testLazyLoadsObjectsOnTheOwningSide() public function testLazyLoadsObjectsOnTheOwningSide()
{ {
$this->_createFixture(); $this->_createFixture();
$this->_em->getConfiguration()->setAllowPartialObjects(false);
$metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct');
$metadata->getAssociationMapping('features')->fetchMode = AssociationMapping::FETCH_LAZY; $metadata->getAssociationMapping('features')->fetchMode = AssociationMapping::FETCH_LAZY;