Ticket #1556 (closed defect: fixed)
Doctrine_Query_Registry should add and return clone of the query
| Reported by: | honza.trtik | Owned by: | romanb |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.0.4 |
| Component: | Query/Hydration | Version: | 1.0.2 |
| Severity: | Keywords: | query registry | |
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | yes |
Description
Folowing example is selfexplaining the issue:
$r = Doctrine_Manager::getInstance()->getQueryRegistry();
// Add new query - list ordered by permission attribute
$q1 = Doctrine_Query::create()->from('sfGuardUser')->orderBy('username');
$r->add('sfGuardUser/list', $q1);
var_dump($q1->getDql()); // string(35) " FROM sfGuardUser ORDER BY username"
// Get this query from registry and adjust it
$q2 = $r->get('list', 'sfGuardUser');
$q2->orderBy('password');
var_dump($q2->getDql()); // string(35) " FROM sfGuardUser ORDER BY password"
// Try to get original added query from registry
$q3 = $r->get('list', 'sfGuardUser');
var_dump($q3->getDql()); // string(35) " FROM sfGuardUser ORDER BY password"
If you add query to registry, get it again and adjust via fluent query interface, you change query object in registry. That is not expected behavior, i think.. IMHO the solution is cloning query before adding and before returning.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.