[Dbix-class] Re: Testing for a join

Eden Cardim edencardim at gmail.com
Tue Dec 21 21:32:36 GMT 2010


>>>>> "Bill" == Bill Moseley <moseley at hank.org> writes:

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

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

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

The suggestion is that you drop that approach altogether and use proper
OO instead. If you join via ->related_resultset, you'll get the
appropriate resultset object and you can run methods on it without
resorting to monkey-patching against the DBIC internals, i.e.:

$rs->related_resultset('foo')

vs

$rs->search({}, {join => 'foo'})

And then you can spread out the "check" logic in each resultset class
appropriately.

Of course, this doesn't work for multiple joins, and I'd suggest a view
for that anyway.

-- 
     Eden Cardim            Need help with your perl Catalyst or DBIx::Class project?
   Software Engineer                   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.        Want a managed development or deployment platform?
http://blog.edencardim.com             http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list