Details
-
Bug
-
Resolution: Fixed
-
Blocker
-
COmanage Registry 0.9.3 (Essential Enneagon Plus Plus Plus)
-
None
Description
When a model with ChanelogBehavior enabled uses a query for find that directly includes a join, for example
$args = array();
$args['joins'][0]['table'] = 'co_group_members';
$args['joins'][0]['alias'] = 'CoGroupMember';
$args['joins'][0]['type'] = 'INNER';
$args['joins'][0]['conditions'][0] = 'CoPerson.id=CoGroupMember.co_person_id';
the existing code adds conditions to the query resulting in SQL that may never return rows (it will not in particular if the join is a LEFT join).
The fundamental problem is that the conditions added because of the join are added as constraints on the results after the SQL JOIN. When a LEFT join is used it is possible for the resulting columns from the joined table to be NULL if there is no data to "join up". The added conditions test for IS NOT true against that NULL and that can never be satisfied with, at least, MySQL.