Add support for IN(?) queries in repositories using the DBAL support for parameter lists.
This commit is contained in:
parent
3d37e436dd
commit
03630df20d
@ -22,6 +22,7 @@ namespace Doctrine\ORM\Persisters;
|
||||
use PDO,
|
||||
Doctrine\DBAL\LockMode,
|
||||
Doctrine\DBAL\Types\Type,
|
||||
Doctrine\DBAL\Connection,
|
||||
Doctrine\ORM\ORMException,
|
||||
Doctrine\ORM\OptimisticLockException,
|
||||
Doctrine\ORM\EntityManager,
|
||||
@ -1281,7 +1282,7 @@ class BasicEntityPersister
|
||||
} else {
|
||||
throw ORMException::unrecognizedField($field);
|
||||
}
|
||||
$conditionSql .= ' = ?';
|
||||
$conditionSql .= (is_array($value)) ? ' IN (?)' : ' = ?';
|
||||
}
|
||||
return $conditionSql;
|
||||
}
|
||||
@ -1373,6 +1374,10 @@ class BasicEntityPersister
|
||||
if (isset($this->_class->fieldMappings[$field])) {
|
||||
$type = Type::getType($this->_class->fieldMappings[$field]['type'])->getBindingType();
|
||||
}
|
||||
if (is_array($value)) {
|
||||
$type += Connection::ARRAY_PARAM_OFFSET;
|
||||
}
|
||||
|
||||
$params[] = $value;
|
||||
$types[] = $type;
|
||||
}
|
||||
|
@ -1953,14 +1953,6 @@ class UnitOfWork implements PropertyChangedListener
|
||||
// TODO: This is very imperformant, ignore it?
|
||||
$newValue = $this->em->find($assoc['targetEntity'], $associatedId);
|
||||
}
|
||||
|
||||
// TODO: Is there a faster approach?
|
||||
$this->eagerLoadingEntities[$assoc['targetEntity']] = array_merge_recursive(
|
||||
$this->eagerLoadingEntities[$assoc['targetEntity']],
|
||||
array_map(function($id) {
|
||||
return array($id);
|
||||
}, $associatedId)
|
||||
);
|
||||
} else {
|
||||
$newValue = $this->em->getProxyFactory()->getProxy($assoc['targetEntity'], $associatedId);
|
||||
}
|
||||
@ -2012,8 +2004,6 @@ class UnitOfWork implements PropertyChangedListener
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
* @return void
|
||||
*/
|
||||
public function triggerEagerLoads()
|
||||
@ -2022,6 +2012,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
return;
|
||||
}
|
||||
|
||||
// avoid infinite recursion
|
||||
$eagerLoadingEntities = $this->eagerLoadingEntities;
|
||||
$this->eagerLoadingEntities = array();
|
||||
|
||||
@ -2032,7 +2023,6 @@ class UnitOfWork implements PropertyChangedListener
|
||||
}
|
||||
|
||||
/**
|
||||
>>>>>>> DDC-952 - Implemented first approach for batching eager loads of ToOne associations.
|
||||
* Initializes (loads) an uninitialized persistent collection of an entity.
|
||||
*
|
||||
* @param PeristentCollection $collection The collection to initialize.
|
||||
|
2
lib/vendor/doctrine-dbal
vendored
2
lib/vendor/doctrine-dbal
vendored
@ -1 +1 @@
|
||||
Subproject commit 556351d9d6b4a33506f2c1535cccee34faa65d62
|
||||
Subproject commit 9cd6df38d841abb4719286ea35a1b37aa2679f8d
|
@ -63,7 +63,7 @@ class DDC633Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->_em->clear();
|
||||
|
||||
$appointments = $this->_em->createQuery("SELECT a FROM " . __NAMESPACE__ . "\DDC633Appointment a")->getResult();
|
||||
|
||||
|
||||
foreach ($appointments AS $eagerAppointment) {
|
||||
$this->assertType('Doctrine\ORM\Proxy\Proxy', $eagerAppointment->patient);
|
||||
$this->assertTrue($eagerAppointment->patient->__isInitialized__, "Proxy should already be initialized due to eager loading!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user