Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2915

When there are 2 identical aliases in an object hydrated dql query tied to a relation, some times it retrives an empty relation

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Invalid
    • Affects Version/s: 2.4.1
    • Fix Version/s: None
    • Component/s: DQL
    • Security Level: All
    • Labels:
      None
    • Environment:
      Debian Squeeze

      Description

      Hi

      I recently had a problem with a Dql query I wrote where when I had a typo in my select which resulted in a very odd behavior. At a predictable row number one of the relations wouldn't hydrate.

      This resulted in the fatal error when I tried to access the relation like so: $row->getLolGameSize()->getName()

      Call to a member function getName() on a non-object

      Here is the query that causes the problem – removing the second reference to lgs in the select fixes the problem.

      SELECT lst, ls, lr, lt, lstlt, lgt, lgs, lgs, ats
      FROM Team\Entity\Lolsummonertournament lst
      INNER JOIN lst.lolSummoner ls
      INNER JOIN ls.lolRank lr
      INNER JOIN ls.lolTier lt
      LEFT JOIN lst.lolTier lstlt
      INNER JOIN lst.lolGameType lgt
      INNER JOIN lst.lolGameSize lgs
      INNER JOIN lst.attendanceStatus ats
      WHERE lst.tournament = :tournamentId
      AND ls.summonerId IS NOT NULL
      AND ls.mmr IS NOT NULL
      ORDER BY ls.mmr desc

      All the best

        Activity

        Hide
        Marco Pivetta added a comment -

        Fetch joining on filtered associations is very dangerous and unsupported.

        Show
        Marco Pivetta added a comment - Fetch joining on filtered associations is very dangerous and unsupported.

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            will ferrer
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: