[Dbix-class] Re: Testing for a join

Bill Moseley moseley at hank.org
Tue Dec 21 16:20:19 GMT 2010


Hi Eden,

On Mon, Dec 20, 2010 at 10:46 AM, Eden Cardim <edencardim at gmail.com> wrote:

> >>>>> "Bill" =3D=3D Bill Moseley <moseley at hank.org> writes:
>
>    Bill> That lists the relationships on a source.  And I'm looking for
> join info on a resultset.
>
>    Bill> I resorted to matching either $rs->result_class or using
>    Bill> Data::Visitor on $rs->{attrs}{join} and looking for the
>    Bill> join.  Doesn't seem that sound of a solution, but appears to
>    Bill> be working ok in my initial tests.
>
> Isn't it easier just "cross" the join via ->related_resultset which
> gives you the correct resultset?
>
> ->resultset('CD')->related_resultset('label')->check_deleted;
> ->resultset('CD')->related_resultset('tracks')->check_deleted;
>
> and you'd implement check_deleted() on RS::Label and RS::Track without
> having to know whether 'CD' is joined or not.
>

Sorry, perhaps I am misunderstanding your suggestion.  My question was:

For any resultset "$rs", determine if it's joined to (or selects from) table
"foo", and if so, what is the alias for that table.

The idea is to have a single place that can add in the criteria to all
resultsets that join to a given table.


-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20101221/5d8=
bb10d/attachment.htm


More information about the DBIx-Class mailing list