ZF-4052: Bug with join queries?


See… for details. This might already be fixed.


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

SELECT count( AS "total_comments", count( AS "total_votes" FROM "comments" AS "c" LEFT JOIN "votes" AS "v" ON = 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( AS "total_comments", count( AS "total_votes" FROM "deals"
 LEFT JOIN "comments" AS "c" ON = c.deal_id
 LEFT JOIN "votes" AS "v" ON = 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...