#1559: Doctrine hydrates only one row of LEFT JOINed table when sorted by an
aggregate
-----------------------------------+----------------------------------------
Reporter: cedsadai | Owner: romanb
Type: defect | Status: new
Priority: major | Milestone: Unknown
Component: Query/Hydration | Version: 1.0.3
Keywords: | Has_test: 0
Mystatus: Pending Core Response | Has_patch: 0
-----------------------------------+----------------------------------------
When sorted by an aggregate, DQL queries fetch only one row of the related
tables.
Example one
{{{
$dql = Doctrine_Query::create()
->select('a.*, p.*, MAX(p.created_at) AS last_updated')
->from('Artist a')
->leftJoin('a.Pictures p')
->orderBy('last_updated DESC')
->groupBy('a.id');
}}}
Will return something like this:
{{{
Array
(
[0] => Array
(
[id] => 2
[name] => Cedric
[created_at] => 2008-10-02 15:10:00
[updated_at] => 2008-10-02 15:10:00
[deleted] =>
[last_updated] => 2008-10-09 01:42:39
[Pictures] => Array
(
[0] => Array
(
[id] => 1
[uploaded_by] => 3
[created_at] => 2008-10-02 15:10:00
[updated_at] => 2008-10-02 15:10:00
[last_updated] => 2008-10-09 01:42:39
)
)
)
etc...
}}}
Of course, my table is fed with records, and the artist of ID 2 has at
least 30 pictures in the databse, that are properly returned when doing a
simple query like "SELECT from Artist a LEFT JOIN a.Pictures p".
Here is a second example of query where the error occurs:
{{{
$dql = Doctrine_Query::create()
->select('a.*, p.*, COUNT(DISTINCT p.id) as total')
->from('Artist a')
->leftJoin('a.Pictures p')
->orderBy('total DESC')
->groupBy('a.id');
}}}
--
Ticket URL: <http://trac.doctrine-project.org/ticket/1559>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"doctrine-svn" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---