Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1465

Fetching partial objects doesn't work if HINT_FORCE_PARTIAL_LOAD is not explicitly used

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major 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

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Julien Pauli
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: