Re: Feature request - Allow searching columns of related tables in search() and search_like()

[prev] [thread] [next] [Date index for 2005/01/10]

From: Tony Bowden
Subject: Re: Feature request - Allow searching columns of related tables in search() and search_like()
Date: 23:12 on 10 Jan 2005
On Mon, Jan 10, 2005 at 03:00:46PM -0500, Cees Hek wrote:
> How about this for a starting point?
> 
> @cds = Music::CD->search('cd.year' => 1990, 'artist.name' => 'Neil Young', {
>   order_by => 'cd.artist',
>   joins        => { artist => 'Music::Artist', cd => 'Music::CD' }
> });

looks quite nasty to me. 

Although I'm intrigued by the idea of setting this up per search. I was
expecting it to be another compile time option somehow. A more advanced
version of has_many...

I guess the definitive version of this is Stars, Roles, and Films:

Star->has_many(roles => Role)
Film->has_many(stars => Star)
Role->has_a(film => Film)
Role->has_a(star => Star)

Star->??? ; # gives us 'films' method
Film->??? ; # gives us 'roles' method

We want something that will allow us to run searches like:

$star->films(film.year => 1982);

$sean->films(role.name => "James Bond");

Of course, assuming we can work out what classes to use, we also know
what the columns in each table will be, so we would only actually
require the fully qualified column if it were ambiguous. For the first
we could probably just say

  $star->films(film.year => 1982);

as Role is unlikely to have a 'year'.

If Film also had a 'name' though, the FQ version would still be
required in the second.  If the column were 'title' instead, it would
be unambiguous.


IMO the key is just coming up with the syntax that links the various tables
together.

Tony

(message missing)

Re: Feature request - Allow searching columns of related tables in search() and search_like()
Tony Bowden 23:12 on 10 Jan 2005

Generated at 12:48 on 22 Feb 2005 by mariachi v0.52