#5968: HABTM association rows with foreign-model conditions cannot be deleted, 
due
to invalid SQL
--------------------------+-------------------------------------------------
    Reporter:  maular     |          Type:  Bug   
      Status:  new        |      Priority:  Medium
   Milestone:  1.2.x.x    |     Component:  Model 
     Version:  1.2 Final  |      Severity:  Normal
    Keywords:             |   Php_version:  n/a   
Cake_version:  7973       |  
--------------------------+-------------------------------------------------
 Ticket #5798 was that HABTM conditions were not being used when HABTM join
 rows were deleted.  The fix for that ticket now means that join conditions
 are always used when deleting - which will fail when those conditions
 refer to either model (not the join model itself).

 Given the model below:
 {{{
 class Group extends AppModel
 {
         var $name = 'Group';
         var $hasAndBelongsToMany = array(
                 'Post' => array(
                         'className' => 'Post',
                         'conditions' => array('Post.archived' => 0)
                 ),
         );
 }
 }}}

 any delete on this will attempt to delete the join rows (GroupsPosts) with
 the 'Post.archived' condition:
 {{{
 $this->Group->del(3);

 SELECT COUNT(*) AS `count` FROM `groups` AS `Group` WHERE `Group`.`id` = 3

 SELECT `GroupsPost`.`post_id` FROM `groups_posts` AS `GroupsPost` WHERE
 `group_id` = 3 AND `Post`.`archived` = 0
 ## 1054: Unknown column 'Post.archived' in 'where clause'

 DELETE FROM `groups` WHERE `groups`.`id` = 3
 }}}

 As no join rows are found (invalid SQL), then none are removed.  Using
 Cake 1.2 r7973

-- 
Ticket URL: <https://trac.cakephp.org/ticket/5968>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to