[Catalyst] CDBI::Sweet wishlist

Matt S Trout catalyst at trout.me.uk
Fri Jul 8 18:46:58 CEST 2005


On Fri, Jul 08, 2005 at 11:46:52AM -0400, James Tolley wrote:
> > Sweet will already let you do -
> >
> > MyApp::Artist->search({ year => '2001', 'cd.name' => "foo" });
> 
> I don't think that it will accept a fieldname for a different table without
> the tablename attached, will it? (year is supposed to refer to cds.year)

Oh right. No, it needs the *relation* name, not the table name, so yes it'd
need to be 'cds.' in both cases. This does mean you can search across
a many-to-many, though -

My::Left -> My::Link <- My::Right

My::Left->search({ 'link.right_id' => $right_obj });

Also, Sweet will automatically pick with method to call if you pass an
object - in this case it'll call the primary column, but if you e.g. did

MyApp::Artist->search({ 'cds.year' => $cd });

it would pull the $cd->year value and use that for the search.

Not quite as DWIM-ish as what you were originally suggesting, but not bad :)

-- 
     Matt S Trout           Website: http://www.shadowcatsystems.co.uk
  Technical Director        E-mail:  mst (at) shadowcatsystems.co.uk
Shadowcat Systems Ltd.



More information about the Catalyst mailing list