Issues

ZF-4052: Bug with join queries?

Description

See http://ajaxray.com/blog/2008/… for details. This might already be fixed.

Comments

The query described in the blogpost will generate a query similar to this one:


SELECT count(c.id) AS "total_comments", count(v.id) AS "total_votes" FROM "comments" AS "c" LEFT JOIN "votes" AS "v" ON delas.id = v.deal_id GROUP BY "foo"."id"

As far as I can see there is no sane reason for anyone to paginate this kind of query: it will always return one row with two columns (total_comments and total_votes). So, the result described in the blog post as being wrong is actually correct. I'm curious to see if the bug the author describes is present in normal JOIN queries (that is, queries without COUNTs as columns). Without feedback, this bug won't get any attention and it will be closed as Not An Issue.

Correction of query in last comment:


SELECT "deals".*, count(c.id) AS "total_comments", count(v.id) AS "total_votes" FROM "deals"
 LEFT JOIN "comments" AS "c" ON deals.id = c.deal_id
 LEFT JOIN "votes" AS "v" ON deals.id = v.deal_id GROUP BY "deals"."id"

I'm still not sure if this would actually cause a problem... the adapter the blog post describes is old and there have been quite a lot of updates since then...