diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 7e69b4865d0..633c9fa0db3 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -6,6 +6,7 @@ use Doctrine\Common\Lexer\Token; use Doctrine\Deprecations\Deprecation; +use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query; @@ -1844,11 +1845,15 @@ public function JoinAssociationDeclaration() */ public function PartialObjectExpression() { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8471', - 'PARTIAL syntax in DQL is deprecated.' - ); + $hydratationMode = $this->query->getHydrationMode(); + + if ($hydratationMode === AbstractQuery::HYDRATE_OBJECT || $hydratationMode === AbstractQuery::HYDRATE_SIMPLEOBJECT) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/8471', + 'PARTIAL syntax in DQL is deprecated.' + ); + } $this->match(Lexer::T_PARTIAL);