Project

General

Profile

Bug #79330

Updated by Morton Jonuschat almost 8 years ago

Before Extbase was converted to use Doctrine the method used a <pre>COUNT(DISTINCT uid)</pre> COUNT(DISTINCT uid) to count on joined tables. With the migration to Doctrine this was changed to use GROUP BY uid. This works in most cases, for this use case it ends up with a different resultset. 
 This is visible in the functional tests in the BlogExample. The goal is to count all persons which use a Tag in either of two relations. In total there are three persons using that tag. 1 using it in both relations, and one each using it in one of them.  
 Thus the correct the result of the query is 3. 
 With the old DISTINCT based query the result would be 1 row with a count of 3. This is the intended result. 
 With the GROUP BY based count the resultset consists of three rows, each containing the count of usages per uid. 

 By coincidence MySQL implictly sorts the results in such a way the the first row of the resultset has a count of 3 uses for that uid (the other rows have 1 use each). PostgreSQL for example has the same resultset, but in a different implicit order. The first row has a counted usage of 1.  

 As the current getObjectCountByQuery only uses the first result row as the count the functional tests fail to detect the error on MySQL but it shows up on PostgreSQL. 

Back