[Dbix-class] deleting many-to-many relationship entries in one query

Nigel Metheringham nigel.metheringham at dev.intechnology.co.uk
Wed Jan 19 15:50:43 GMT 2011


On 19 Jan 2011, at 15:33, Leandro Hermida wrote:

>  1. Delete the bridging relationship
>        $person->person2address->delete;
> 
> I tried this but get Can't locate object method "person2address" via package "MySchema::Result::Person"? What did I set up wrong?  In MySchema::Result::Person I have for the relationship:

What version of DBIx::Class are you using?

Whats happening here is $person->person2address is returning (a list of)
row objects.  I thought that this happened in array mode with scalar
mode returning the RS for the query.

In any case, if you want a RS, you can always use the _rs accessor,
so 
	$person->person2address_rs->delete;

will work without any ambiguity (and works in Template Toolkit if
you are playing with objects within templates where the inherent
array mode tends to break stuff).

	Nigel.
--
[ Nigel Metheringham             Nigel.Metheringham at InTechnology.com ]
[ - Comments in this message are my own and not ITO opinion/policy - ]







More information about the DBIx-Class mailing list