Skip to content

Commit 6874448

Browse files
authored
Undeprecate PARTIAL for array hydration. (#11366)
* Undeprecate PARTIAL for array hydration. * note about undeprecate partial in UPGRADE.md
1 parent bf3e082 commit 6874448

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

UPGRADE.md

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ to find out.
1515

1616
Use `Doctrine\ORM\Query\TokenType::T_*` instead.
1717

18+
## PARTIAL DQL syntax is undeprecated for non-object hydration
19+
20+
Use of the PARTIAL keyword is not deprecated anymore in DQL when used with a hydrator
21+
that is not creating entities, such as the ArrayHydrator.
22+
1823
# Upgrade to 2.17
1924

2025
## Deprecate annotations classes for named queries

src/Query/Parser.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -1844,11 +1844,13 @@ public function JoinAssociationDeclaration()
18441844
*/
18451845
public function PartialObjectExpression()
18461846
{
1847-
Deprecation::trigger(
1848-
'doctrine/orm',
1849-
'https://github.com/doctrine/orm/issues/8471',
1850-
'PARTIAL syntax in DQL is deprecated.'
1851-
);
1847+
if ($this->query->getHydrationMode() === Query::HYDRATE_OBJECT) {
1848+
Deprecation::trigger(
1849+
'doctrine/orm',
1850+
'https://github.com/doctrine/orm/issues/8471',
1851+
'PARTIAL syntax in DQL is deprecated for object hydration.'
1852+
);
1853+
}
18521854

18531855
$this->match(TokenType::T_PARTIAL);
18541856

src/UnitOfWork.php

+10
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
use Doctrine\ORM\Persisters\Entity\JoinedSubclassPersister;
4242
use Doctrine\ORM\Persisters\Entity\SingleTablePersister;
4343
use Doctrine\ORM\Proxy\InternalProxy;
44+
use Doctrine\ORM\Query\SqlWalker;
4445
use Doctrine\ORM\Utility\IdentifierFlattener;
4546
use Doctrine\Persistence\Mapping\RuntimeReflectionService;
4647
use Doctrine\Persistence\NotifyPropertyChanged;
@@ -2919,6 +2920,15 @@ private function newInstance(ClassMetadata $class)
29192920
*/
29202921
public function createEntity($className, array $data, &$hints = [])
29212922
{
2923+
if (isset($hints[SqlWalker::HINT_PARTIAL])) {
2924+
Deprecation::trigger(
2925+
'doctrine/orm',
2926+
'https://github.com/doctrine/orm/issues/8471',
2927+
'Partial Objects are deprecated for object hydration (here entity %s)',
2928+
$className
2929+
);
2930+
}
2931+
29222932
$class = $this->em->getClassMetadata($className);
29232933

29242934
$id = $this->identifierFlattener->flattenIdentifier($class, $data);

0 commit comments

Comments
 (0)