Skip to content

Commit

Permalink
[doctrineGH-8471] Deprecate Partial DQL syntax and forcing partial lo…
Browse files Browse the repository at this point in the history
…ads.
  • Loading branch information
beberlei committed Feb 12, 2021
1 parent 6fe388a commit 722ce8a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Doctrine/ORM/Query/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Doctrine\ORM\Query;

use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Query;
Expand Down Expand Up @@ -1870,6 +1871,12 @@ public function JoinAssociationDeclaration()
*/
public function PartialObjectExpression()
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8471',
'PARTIAL syntax in DQL is deprecated.'
);

$this->match(Lexer::T_PARTIAL);

$partialFieldSet = [];
Expand Down
8 changes: 8 additions & 0 deletions lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\LockMode;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\Cache\Persister\CachedPersister;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\ListenersInvoker;
Expand Down Expand Up @@ -2750,6 +2751,13 @@ public function createEntity($className, array $data, &$hints = [])

// Properly initialize any unfetched associations, if partial objects are not allowed.
if (isset($hints[Query::HINT_FORCE_PARTIAL_LOAD])) {
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8471',
'Partial Objects are deprecated (here entity %s)',
$className
);

return $entity;
}

Expand Down

0 comments on commit 722ce8a

Please sign in to comment.