Almost forgot ... here's the link to the ticket:
https://trac.cakephp.org/ticket/4202
On Jun 7, 1:42 pm, floob <[EMAIL PROTECTED]> wrote:
> Has anyone ever deleted from a Model that has dependent joins with
> conditions, and realized that more rows got deleted than they
> expected?
>
> To give an example, let's declare 3 classes, Book Cd and
> OverallFavorite. OverallFavorite stores your prioritized rank of all
> of your favorite stuff ... favorite book, cd, bike, framework,
> whatever. So, since we're joining many models to a single model, in
> addition to a foreign key ID, the OverallFavorite model ALSO needs to
> store which table that ID is references (classic compound key
> situation).
>
> The Book class would look like:
>
> Book extends AppModel{
> ...
> var $hasOne = array('OverallFavorite' => array('foreignKey' =>
> 'model_id', 'dependent' => true, 'conditions' =>
> 'OverallFavorite.model_type = "Book"' );
> ...
>
> }
>
> What happens is, if you delete a book entry, the conditions aren't
> being used. EVERY row in OverallFavorite with the same foreignKey id
> gets deleted. If you have Cd, Book, and Framework, all with id=1 in
> their tables, all three of those entries are deleted.
>
> I ran into this yesterday, almost wrote up a new ticket ticket, and
> found a 4-month old bug that was closed (not solved) with the
> identical description. I tacked on a test case to push that ticket
> along, but I'm still curious about this bug. So, my questions are:
> Has anyone else had this problem before? Is anyone EXPECTING this
> delete-happy behavior to happen? Is there some other understood
> workaround for this?
>
> Thanks all,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---