Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.1.2
-
Fix Version/s: None
-
Component/s: DQL
-
Security Level: All
-
Labels:None
Description
Using the DQL "partial" keyword is not enough to get a partial entity as a result.
The DQL hint HINT_FORCE_PARTIAL_LOAD must be used as well.
$q = $em->createQuery('SELECT partial r.{id,comment} FROM Entities\Rating r WHERE r.id=3');
$r = $q->getResult() /* HYDRATE_OBJECT is the default hydration mode */
Here, $r contains the full Entity, a SELECT * has been sent
$q = $em->createQuery('SELECT partial r.{id,comment} FROM Entities\Rating r WHERE r.id=3');
$q->setHint(Doctrine\ORM\Query::HINT_FORCE_PARTIAL_LOAD, 1);
$r = $q->getResult() /* HYDRATE_OBJECT is the default hydration mode */
Here, $r contains only the selected fields, hence a true partial Entity
Issue Links
- duplicates
-
DDC-624
Partial object query that leaves out an association to avoid loading it fetches the association anyway.
-