[Catalyst] CDBI::Sweet wishlist

Matt S Trout catalyst at trout.me.uk
Fri Jul 8 16:34:56 CEST 2005

On Fri, Jul 08, 2005 at 01:00:30PM +0100, Will Hawes wrote:
> Not sure if it's been released yet, but the most recent version of Sweet (see Catalyst SVN) does something similar to what you describe.

0.04 is currently on CPAN; everything since 0.02 has the same feature set, the
extra releases have been bug and test fixes.

> ----- Original Message -----
> From: James Tolley <james at bitperfect.com>
> > > If there's anything you would like to be able to do with cdbi/sweet but
> > > currently can't I'd be extremely interested in use cases and for
> > preference
> > > samples of "it would be nice if I can write this code and have it work".
> > 
> > You asked for it! :-) This is similar to my understanding of what
> > Rob::Database (posted recently) does:
> > 
> > I'd like to be able to provide a minimal query, and have all of the joins
> > happen automatically, based upon the relationships defined through CDBI.
> > Based upon the CDBI perldoc examples:
> > 
> > my @artists = MyApp::Artist->select({
> >   year => '2001',  # unambiguous fieldname
> >   style => 'Blues', # arbitrary number of joins (artist -> cd ->
> > style_ref -> style)
> > },     { order_by => 'artistid DESC' });

Sweet will already let you do -

MyApp::Artist->search({ year => '2001', 'cd.name' => "foo" });

but it can only join to adjacent tables currently. I'm working on that.

> > The style field might be a little over the top, since there are two style
> > fields in the db: style_ref.style and style.style, but you get the idea...
> > of course, we _could_ say that the arg to style ('Blues') isn't numeric, so
> > it must be referring to style.style, which holds chars...?

I think I'd rather sort out an explicit syntax first, then provide stuff
like this. It'd probably be possible to port Rob K's graphing algorithm
to produce a plugin that provided a "best guess", but I worry about this
doing something you didn't mean far too easily.

> > Of course, the icing on the cake would be if then:
> > 
> > my @cds = $artists[0]->cds; # only matching cds returned.
> > 
> > But I can't quite work out whether or not that would mean that only certain
> > styles would be returned from $cd->styles. That wouldn't be DWIMmish...

Hmm. I don't think the returned object should be tied so closely to the
search, though. It's an interesting thought, mind - maybe some sort of
search return object that could do that is in order?

     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