Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-712

allow RIGHT JOIN or specifying the root class of the hydratation tree

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: DQL, ORM
    • Security Level: All
    • Labels:
      None

      Description

      Hi! Let me start by saying you guys did a great job with Doctrine 1 and that I can't wait to start using Doctrine2

      I will explain this feature request with an example. I have a User entity wich relates one to many to a Picture entity. Picture has a " is main picture" boolean field. Not all users have a main picture. I would like to be able to select all Users, each with their main picutre, if that exists, or some Null value, if it does not exists, in one query, using join. I would also like for the result collection to contain Picture entities on the first level, with the User beinng accessible as an aggregate of Picture.

      The way I can think doing this is by using a RIGHT or LEFT join (not INNER) as to also select Users that don't have a main picture. I can do this by selecting

      SELECT Picture p, p.User u FROM p RIGHT JOIN u WITH p.main=1

      but right joins afik are not available atm in either version of Doctrine, or by selecting

      SELECT User u, u.Picture p FROM u LEFT JOIN p WITH p.main=1

      and somehow instructing the hydrator to consider Picture as the root object for the generated object tree and User as a "child" of Picture.

      For users without a picture, the Picture object would somehow indicate it is NULL, while still holding a refference to the User.

      Makes sense? If there is an alternate way to achieve this, please enlighten me, tough I think it would still add felxibility if we could hint the hydrator for the root object in a tree.

        Activity

        Mihai Ilinca created issue -
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Workflow jira [ 11667 ] jira-feedback [ 13865 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 13865 ] jira-feedback2 [ 15729 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 15729 ] jira-feedback3 [ 17986 ]

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Mihai Ilinca
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: