#5819: CakePHP Revision 7896: HABTM Issue (deleting one relation deletes other
relations)
-------------------------------+--------------------------------------------
Reporter: milmarqtan | Owner:
Type: Bug | Status: reopened
Priority: Critical | Milestone: 1.2.x.x
Component: Model | Version: RC3
Severity: Critical | Resolution:
Keywords: HABTM Delete | Php_version: PHP 5
Cake_version: 1.2.0.7692 RC3 |
-------------------------------+--------------------------------------------
Changes (by Thalagyrt):
* status: closed => reopened
* resolution: fixed =>
Comment:
I just explained an issue where this is clearly insufficient. If both
sides of the relationship are joined - Comment HABTM Blog, Blog HABTM
Comment, then deleting a comment will delete every HABTM entry for the
blog it belongs to, not just the comment and the HABTM entry for that
comment. I don't see *any* case where that would even remotely be
considered proper behavior.
Example:
Comment HABTM Blog
Blog HABTM Comment
Blog id 250
Comment id 4500
In the controller:
$this->Comment->delete(4500);
Delete queries executed:
DELETE FROM `blogs_comments` WHERE `blogs_comments.blog_id` = 250;
DELETE FROM `comments` WHERE `comments.id` = 4500;
The first query should not be executed. It wipes out the relations for
every single comment on that blog, not just that one comment. It makes no
sense relationally for me to not be able to have the comment HABTM the
blog, because honestly, what if I do want to look up a comment and see the
associated entry? I'm normalizing comments for everything here, and they
can HABTM to a few other models as well.
Point me to test cases that show that it should behave this way. Et's
entirely counter-intuitive and makes no sense in any development
environment I've ever heard of or worked in. If this is expected behavior,
then this is, in my opinion, bad design.
--
Ticket URL: <https://trac.cakephp.org/ticket/5819#comment:8>
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
-~----------~----~----~----~------~----~------~--~---