Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-335

Refactor DQL EBNF to use JOIN FETCH as syntax for fetch joins only


    • Type: Improvement
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0-ALPHA4
    • Fix Version/s: 2.0-BETA1
    • Component/s: DQL
    • Security Level: All
    • Labels:


      There are several problems with the current approach on fetch joins:

      1. There is no way to determine in the parser already if a join is fetch or not, this makes it much harder to implement things like @OrderBy or @OrderColumn
      2. A DQL like "SELECT u, g.name FROM User u JOIN u.group g" currently tries to partially load the group object instead of just returning g.name as scalar. This is very unintuiative.

      Solution, change the EBNF too:

      Join                                       ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" [FETCH] JoinAssociationPathExpression 
                                                     ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression]

      Question would be how to specify partial object selects.

      Romans idea was something like:

      select u.{name, other, field, stuff}

      However my take is this would again put information into the select clause that might be interesting elsewhere, so

      SELECT u FROM User u JOIN FETCH u.group PARTIAL id, name

      That way we could add both $isFetchJoin and $isPartial flags to the AST/Join Node plus an additional $partialFields array.

        Issue Links


          beberlei Benjamin Eberlei created issue -
          beberlei Benjamin Eberlei made changes -
          Field Original Value New Value
          Link This issue is required for DDC-195 [ DDC-195 ]
          romanb Roman S. Borschel made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          romanb Roman S. Borschel made changes -
          Status In Progress [ 3 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          beberlei Benjamin Eberlei made changes -
          Workflow jira [ 10891 ] jira-feedback [ 15548 ]
          beberlei Benjamin Eberlei made changes -
          Workflow jira-feedback [ 15548 ] jira-feedback2 [ 17412 ]
          beberlei Benjamin Eberlei made changes -
          Workflow jira-feedback2 [ 17412 ] jira-feedback3 [ 19669 ]


            • Assignee:
              romanb Roman S. Borschel
              beberlei Benjamin Eberlei
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: