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

Leandro Hermida softdev at leandrohermida.com
Wed Jan 19 16:24:34 GMT 2011


On Wed, Jan 19, 2011 at 4:50 PM, Nigel Metheringham <
nigel.metheringham at dev.intechnology.co.uk> wrote:

> 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:
>

Sorry I misspelled the relationship $person->person2address->delete works


> What version of DBIx::Class are you using?
>
>
0.08126


> 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;
>

This works too!


> 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 - ]
>
>
>
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20110119/f16=
97c81/attachment.htm


More information about the DBIx-Class mailing list