diff --git a/UPGRADE.md b/UPGRADE.md index 5689b307bda..9e6c0cb2253 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -15,6 +15,11 @@ to find out. Use `Doctrine\ORM\Query\TokenType::T_*` instead. +## PARTIAL DQL syntax is undeprecated for non-object hydration + +Use of the PARTIAL keyword is not deprecated anymore in DQL when used with a hydrator +that is not creating entities, such as the ArrayHydrator. + # Upgrade to 2.17 ## Deprecate annotations classes for named queries diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 949a8f4ebdd..eb7da7337ac 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -1844,11 +1844,13 @@ public function JoinAssociationDeclaration() */ public function PartialObjectExpression() { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8471', - 'PARTIAL syntax in DQL is deprecated.' - ); + if ($this->query->getHydrationMode() === Query::HYDRATE_OBJECT) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/8471', + 'PARTIAL syntax in DQL is deprecated for object hydration.' + ); + } $this->match(TokenType::T_PARTIAL); diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index b6d509145bc..6875487fa5d 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -41,6 +41,7 @@ use Doctrine\ORM\Persisters\Entity\JoinedSubclassPersister; use Doctrine\ORM\Persisters\Entity\SingleTablePersister; use Doctrine\ORM\Proxy\InternalProxy; +use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Utility\IdentifierFlattener; use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Persistence\NotifyPropertyChanged; @@ -2919,6 +2920,15 @@ private function newInstance(ClassMetadata $class) */ public function createEntity($className, array $data, &$hints = []) { + if (isset($hints[SqlWalker::HINT_PARTIAL])) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/8471', + 'Partial Objects are deprecated for object hydration (here entity %s)', + $className + ); + } + $class = $this->em->getClassMetadata($className); $id = $this->identifierFlattener->flattenIdentifier($class, $data);