Doctrine 1
  1. Doctrine 1
  2. DC-927

Query with left join and group clause returns only one row, even though there are multiple results

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Query
    • Labels:
      None
    • Environment:
      Windows 7-64 bit
      Symfony 1.4.8

      Description

      under certain circumstances, Doctrine will only return one result out of a bunch of results, for example:

      $ symfony doctrine:dql "from Tafel t, t.Reservering r where t.restaurant_id=4 select date(t.tijd), count(t.id) tafels, count(r.id) reserveringen group by date(t.tijd)"
      >> doctrine executing dql query
      DQL: from Tafel t, t.Reservering r where t.restaurant_id=4 select date(t.tijd), count(t.id) tafels, count(r.id) reserveringen group by date(t.tijd)
      found 2 results
      -
      date: '2010-11-14'
      tafels: '1'
      reserveringen: '1'

      Expected outcome:
      found 2 results
      -
      date: '2010-11-14'
      tafels: '1'
      reserveringen: '1'
      -
      date: '2010-11-16'
      tafels: '1'
      reserveringen: '0'

      The query works fine without the left join:
      $ symfony doctrine:dql "from Tafel t where t.restaurant_id=4 select date(t.tijd), count(t.id) tafels group by date(t.tijd)"
      >> doctrine executing dql query
      DQL: from Tafel t where t.restaurant_id=4 select date(t.tijd), count(t.id) tafels, group by date(t.tijd)
      found 2 results
      -
      date: '2010-11-14'
      tafels: '1'
      -
      date: '2010-11-16'
      tafels: '1'

        Activity

        Hide
        Bart van den Burg added a comment -

        As you can see, by the way, it does actually say "found 2 results", but then returns only one.

        Show
        Bart van den Burg added a comment - As you can see, by the way, it does actually say "found 2 results", but then returns only one.
        Hide
        Willem van Duijn added a comment -

        There are multiple reports from people that are hurt by this bug:

        http://www.devcomments.com/doctrine-execute-only-returns-one-row-to286270.htm
        http://www.devcomments.com/Problem-with-Doctrine-and-Join-GroupBy-query-at87536.htm

        Setting the Hydration-mode to HYDRATE_NONE yields multiple result rows (but is not useful).

        Show
        Willem van Duijn added a comment - There are multiple reports from people that are hurt by this bug: http://www.devcomments.com/doctrine-execute-only-returns-one-row-to286270.htm http://www.devcomments.com/Problem-with-Doctrine-and-Join-GroupBy-query-at87536.htm Setting the Hydration-mode to HYDRATE_NONE yields multiple result rows (but is not useful).
        Hide
        Victor Ruiz added a comment -

        Related in some way with multiple order by clauses. If I remove all of them but one it works, the problem appears when I put more than one order by criteria.

        Show
        Victor Ruiz added a comment - Related in some way with multiple order by clauses. If I remove all of them but one it works, the problem appears when I put more than one order by criteria.
        Hide
        Mike Seth added a comment -

        This is a hydration problem that occurs because the ID columns of the joined tables are not SELECT'ed explicitly. The offending code is a loop in the graph base hydrator, but I don't understand it well enough to fix it with any certainty that I don't break anything.

        Show
        Mike Seth added a comment - This is a hydration problem that occurs because the ID columns of the joined tables are not SELECT'ed explicitly. The offending code is a loop in the graph base hydrator, but I don't understand it well enough to fix it with any certainty that I don't break anything.

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Bart van den Burg
          • Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated: