[CDBI] delete from lookup table

WulfDirk.Leuschner at sanofi-aventis.com WulfDirk.Leuschner at sanofi-aventis.com
Thu Oct 27 13:28:04 BST 2005

>On 10/27/05, WulfDirk.Leuschner at sanofi-aventis.com
><WulfDirk.Leuschner at sanofi-aventis.com> wrote:
>> > Peter Speltz [peterspeltz at gmail.com] wrote:
>> >  What i have seen a lot is  is the use or "delete_all" on the results
>> >  from a search.
>> >  $class->search( id => $related_id)->delete_all;
>> >  and if a "my_method" is a has_many accessor i think you can say;
>> >  $self->my_method(id => $id)->delete_all;
>> Unfortunately this does not work - it returns the mapped objects themselves.
>> Thus, using
>> this code you end up deleting both the entry in your lookup table *and* the
>> the record for
>> the mapped object.

>I see what you mean now how the mapping messis everything up.
>Seems CDBI should have a revove_from* method in this case. Should not
>be too hard to write.

You are right. I'd propose to wait if some other people come up with additional ideas and then ask Tony if he thinks it is worth implementing.

More information about the ClassDBI mailing list