diff --git a/composer.json b/composer.json index 6f22e92d8..471ed8a2e 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,7 @@ "phpunit/phpunit": "^9.5", "psalm/plugin-phpunit": "^0.17", "psalm/plugin-symfony": "^3.0", - "rector/rector": "^0.13", + "rector/rector": "^0.14", "sonata-project/block-bundle": "^4.2", "sonata-project/entity-audit-bundle": "^1.1", "symfony/browser-kit": "^4.4 || ^5.4 || ^6.0", diff --git a/src/Model/ModelManager.php b/src/Model/ModelManager.php index 471ab283e..51f8fa262 100644 --- a/src/Model/ModelManager.php +++ b/src/Model/ModelManager.php @@ -345,14 +345,11 @@ public function batchDelete(string $class, BaseProxyQueryInterface $query): void throw new \TypeError(sprintf('The query MUST implement %s.', ProxyQueryInterface::class)); } - $qb = $query->getQueryBuilder(); - $qb->select('DISTINCT '.current($qb->getRootAliases())); - try { $entityManager = $this->getEntityManager($class); $i = 0; - foreach ($qb->getQuery()->toIterable() as $object) { + foreach ($query->execute() as $object) { $entityManager->remove($object); if (0 === (++$i % 20)) {