Commit 219e681a authored by Bernhard Schussek's avatar Bernhard Schussek

Merge branch 'bugfix/maintain-id-order' into 'master'

Maintain order of IDs passed to getMultiple()

See merge request !5
parents 76cbadcd b98cd650
......@@ -137,14 +137,19 @@ abstract class ORMRepository extends EntityRepository implements EditableReposit
return new EmptyCursor();
}
$idStrings = array_map('strval', array_values($ids));
// Index by ID for the ID check below
$aggregates = $this->createQueryBuilder('e', sprintf('e.%s', $this->idField))
->where(sprintf('e.%s IN (:ids)', $this->idField))
->setParameter('ids', array_map('strval', array_values($ids)))
->setParameter('ids', $idStrings)
->getQuery()
->execute();
$cursor = new ArrayCursor($aggregates);
// Maintain the order of IDs
$sortedAggregates = array_replace(array_flip($idStrings), $aggregates);
$cursor = new ArrayCursor($sortedAggregates);
if ($ignoreMissing) {
return $cursor;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment