[Dbix-class] find redux
Matt S Trout
dbix-class at trout.me.uk
Fri Feb 1 07:49:28 GMT 2008
On Wed, Jan 30, 2008 at 07:57:02PM +0100, Zbigniew Lukasiak wrote:
> Hi Matt,
>
> You are a mystery to me - but I'll try to comply and interleave my
> comments with your original post as you wish.
>
> On Jan 24, 2008 1:14 PM, Matt S Trout <dbix-class at trout.me.uk> wrote:
> > =head1 calling cases
> >
> > Case 1 - called with 'key' attr and all columns for that key[0]
> > Case 2 - called with 'key' attr and not all columns for that key
> >
> > Case 3 - called without 'key' attr and with a unique key's worth of cols[0]
> > Case 4 - called without key and no unique set of columns
> >
> > =head1 08000
> >
> > Current behaviour (I think, please correct me if I'm wrong):
> >
> > 1: does the expected query, ignoring other columns
>
> This is not true. Here is example:
>
> my $cd = $schema->resultset("CD")->first;
> my $artist_rs = $schema->resultset("Artist")->search( { artistid =>
> $cd->artist->artistid } );
> $schema->storage->debug(1);
> $artist_rs->find( { name => 'some other name' }, { key => 'primary' }
> ); # this is the query
I can see a potential problem here:
We can't actually ignore the search query from the rs.
Any of it.
Because the search query is often used to restrict what the user can find
-within-.
So
$photos->search({ owned_by => $uid })->find({ id => $photo_id })
has to include the WHERE owned_by = $uid even if the find specifies
key => 'primary'.
However, we -can- ignore keys passed in the find hash. But I'm not sure
we should, except in case of a *_or_* call.
Thoughts, people?
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the DBIx-Class
mailing list