Ticket #1529 (closed defect: fixed)
SoftDeletable Template problem with left join relations
| Reported by: | MrOxiMoron | Owned by: | jwage |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.0.4 |
| Component: | Behaviors | Version: | 1.0.2 |
| Severity: | Keywords: | SoftDeletable | |
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | yes |
Description
I have a Todo and Comments table. a Todo item has many comments. They are both softdeletable. (and use_dql_callbacks set to true)
$todos = Doctrine_Query::create()->from('Todo t')->leftJoin('t.Comments c')->execute();
returns no todo items that have 0 comments.
The query: SELECT t.id AS tid, t.component AS tcomponent, t.user AS tuser, t.title AS ttitle, t.description AS tdescription, t.created_at AS tcreated_at, t.updated_at AS tupdated_at, t.deleted AS tdeleted, c.id AS cid, c.message AS cmessage, c.todo_id AS ctodo_id, c.created_at AS ccreated_at, c.updated_at AS cupdated_at, c.deleted AS cdeleted FROM todo t LEFT JOIN comment c ON t.id = c.todo_id WHERE t.deleted = 0 AND c.deleted = 0
The problem is that for the leftJoin the c.deleted is NULL so it isn't 0 or 1, it simply isn't set.