[DC-927] Query with left join and group clause returns only one row, even though there are multiple results Created: 14/Nov/10  Updated: 19/May/11

Status: Open
Project: Doctrine 1
Component/s: Query
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Bart van den Burg Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 4
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'



 Comments   
Comment by Bart van den Burg [ 14/Nov/10 ]

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

Comment by Willem van Duijn [ 08/Feb/11 ]

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).

Comment by Victor Ruiz [ 18/Feb/11 ]

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.

Comment by Mike Seth [ 19/May/11 ]

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.

Generated at Sat Dec 27 04:30:47 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.