[DoctrineBridge] Fixed submitting ids with query limit or offset
This commit is contained in:
parent
adacae6f54
commit
9bb194098f
@ -62,7 +62,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
|||||||
$metadata = $this->queryBuilder->getEntityManager()->getClassMetadata(current($this->queryBuilder->getRootEntities()));
|
$metadata = $this->queryBuilder->getEntityManager()->getClassMetadata(current($this->queryBuilder->getRootEntities()));
|
||||||
|
|
||||||
foreach ($this->getEntities() as $entity) {
|
foreach ($this->getEntities() as $entity) {
|
||||||
if (\in_array(current($metadata->getIdentifierValues($entity)), $values, true)) {
|
if (\in_array((string) current($metadata->getIdentifierValues($entity)), $values, true)) {
|
||||||
$choices[] = $entity;
|
$choices[] = $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -956,7 +956,32 @@ class EntityTypeTest extends BaseTypeTest
|
|||||||
$this->assertNull($field->getData());
|
$this->assertNull($field->getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDisallowChoicesThatAreNotIncludedQueryBuilderSingleIdentifierWithLimit()
|
public function testSingleIdentifierWithLimit()
|
||||||
|
{
|
||||||
|
$entity1 = new SingleIntIdEntity(1, 'Foo');
|
||||||
|
$entity2 = new SingleIntIdEntity(2, 'Bar');
|
||||||
|
$entity3 = new SingleIntIdEntity(3, 'Baz');
|
||||||
|
|
||||||
|
$this->persist([$entity1, $entity2, $entity3]);
|
||||||
|
|
||||||
|
$repository = $this->em->getRepository(self::SINGLE_IDENT_CLASS);
|
||||||
|
|
||||||
|
$field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [
|
||||||
|
'em' => 'default',
|
||||||
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
|
'query_builder' => $repository->createQueryBuilder('e')
|
||||||
|
->where('e.id IN (1, 2, 3)')
|
||||||
|
->setMaxResults(1),
|
||||||
|
'choice_label' => 'name',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$field->submit('1');
|
||||||
|
|
||||||
|
$this->assertTrue($field->isSynchronized());
|
||||||
|
$this->assertSame($entity1, $field->getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDisallowChoicesThatAreNotIncludedByQueryBuilderSingleIdentifierWithLimit()
|
||||||
{
|
{
|
||||||
$entity1 = new SingleIntIdEntity(1, 'Foo');
|
$entity1 = new SingleIntIdEntity(1, 'Foo');
|
||||||
$entity2 = new SingleIntIdEntity(2, 'Bar');
|
$entity2 = new SingleIntIdEntity(2, 'Bar');
|
||||||
|
Reference in New Issue
Block a user