#1635: Query work in mysql, not in postgresql
------------------------------+---------------------------------------------
Reporter: sikkle | Owner: romanb
Type: defect | Status: new
Priority: minor | Milestone: Unknown
Component: Query/Hydration | Version: 1.0.3
Resolution: | Keywords: postgresql query
Has_test: 0 | Mystatus: Pending Core Response
Has_patch: 0 |
------------------------------+---------------------------------------------
Comment (by adrive):
This is not a Doctrine problem.
Try to run this SQL query in MySQL and PostgreSQL and if you can, try also
Oracle:
{{{
SELECT b.id, b.title, COUNT(c.id) AS num_comments FROM blog b JOIN
comments c ON b.id = c.blog_id GROUP BY b.id
}}}
Only MySQL executes the select and returns you the results.
Oracle or PostgreSQL will raise an error, because you must have all fields
that are in select clause in GROUP BY clause. The reason why I think that
MySQL is not working with groupping correctly is out of this ticket.
Therefor there are two possible solutions on this ticket:
1) You should have in mind, that all columns that appear in SELECT clause
and are not used in aggregate function must be also listed in GROUP BY
clause
2) Doctrine should guess, which columns are in SELECT clause used in non
aggregate context and place them also in GROUP BY clause automatically,
when aggregate function is used and no column in group by was used, this
should be a nice enhancement.
--
Ticket URL: <http://trac.phpdoctrine.org/ticket/1635#comment:1>
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
-~----------~----~----~----~------~----~------~--~---