Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1225

Invalid SQL generated (extra comma) when joining to entity with composite PK

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.1.2, 2.2
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

                  $qb->from('Tournaments_Model_StageBracketTeamRegistration', 'r')
                     ->innerJoin('r.teamSelection', 'ts')
                     ->innerJoin('ts.players', 'tsp')
                     ->select('r, ts, tsp')
                     ->where('r.stageBracket = ?1')
                     ->andWhere('r.opponentIsReserve = false')
                     ->orderBy('r.registrationDateTime')
                     ->setParameter(1, $bracket);

      Generates:

      SELECT s0_.id AS id0, s0_.opponent_is_reserve AS opponent_is_reserve1, s0_.opponent_checked_in AS opponent_checked_in2, s0_.registration_date_time AS registration_date_time3, t1_.id AS id4,, s0_.type AS type5, s0_.stage_bracket_id AS stage_bracket_id6, s2_.team_selection_id AS team_selection_id7, t1_.team_id AS team_id8, t3_.team_selection_id AS team_selection_id9, t3_.player_id AS player_id10
      FROM stage_bracket_team_registrations s2_
      INNER JOIN stage_bracket_registrations s0_ ON s2_.id = s0_.id
      INNER JOIN team_selections t1_ ON s2_.team_selection_id = t1_.id
      INNER JOIN team_selection_players t3_ ON t1_.id = t3_.team_selection_id
      WHERE s0_.stage_bracket_id = 22 AND s0_.opponent_is_reserve = 0
      ORDER BY s0_.registration_date_time ASC

      Note the 2nd comma after "t1_.id AS id4". TeamSelectionPlayer uses a composite PK. I have attached the relevant entity classes.

        Activity

        Glen Ainscow created issue -
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.1.1 [ 10153 ]
        Resolution Fixed [ 1 ]
        Glen Ainscow made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Guilherme Blanco made changes -
        Status Reopened [ 4 ] Closed [ 6 ]
        Assignee Benjamin Eberlei [ beberlei ] Guilherme Blanco [ guilhermeblanco ]
        Fix Version/s 2.2-DEV [ 10157 ]
        Fix Version/s 2.1.1 [ 10153 ]
        Resolution Incomplete [ 4 ]
        Glen Ainscow made changes -
        Resolution Incomplete [ 4 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        Glen Ainscow made changes -
        Attachment models.zip [ 11048 ]
        Guilherme Blanco made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Fix Version/s 2.1.2 [ 10154 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 12744 ] jira-feedback [ 14915 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14915 ] jira-feedback2 [ 16779 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 16779 ] jira-feedback3 [ 19032 ]

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Glen Ainscow
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: