[Dbix-class] doubt about has_many and update
Peter Rabbitson
rabbit+dbic at rabbit.us
Mon Feb 2 19:28:01 GMT 2015
On 02/02/2015 05:53 PM, Luca Ferrari wrote:
> So far, what I've done is to "emulate" the set method as follows:
>
> ...
>
> and therefore delete each joined object
I think you are missing the fact that resultsets are strictly additive.
Thus $some_object->some_has_many->delete will do *exactly* what you
expect (delete all the related pieces of the has_many that relates to
$some_object).
The following also works as you'd expect:
$schema->resultset('Something')
->search({ some arbitrary conditions })
->search_related('SomeHasManys')
->delete;
Does this answer the question?
More information about the DBIx-Class
mailing list