On Feb 13, 2008 5:51 PM, Guillermo Roditi <[EMAIL PROTECTED]> wrote:
> > I attach a patch (against
> > http://dev.catalyst.perl.org/repos/bast/DBIx-Class/0.08/trunk) that
> > does more or less that - when you specify the unique key it ignores
> > all columns from the query that don't belong to it (
>
> I find this to be desired behavior Zbigniew Lukasiak++
Thanks. Frankly I don't think that warning is necessary - I like to
use find directly from the query parameters without removing all the
unneeded columns. Without it that patch is even more trivial
(attached here).
--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
Index: t/61findnot.t
===================================================================
--- t/61findnot.t (revision 4075)
+++ t/61findnot.t (working copy)
@@ -7,7 +7,7 @@
my $schema = DBICTest->init_schema();
-plan tests => 17;
+plan tests => 18;
my $art = $schema->resultset("Artist")->find(4);
ok(!defined($art), 'Find on primary id: artist not found');
@@ -44,3 +44,9 @@
@cd = $cd->single;
cmp_ok(@cd, '==', 1, 'Return something even in array context');
ok(@cd && !defined($cd[0]), 'Array contains an undef as only element');
+
+$cd = $schema->resultset("CD")->first;
+my $artist_rs = $schema->resultset("Artist")->search( { artistid => $cd->artist->artistid } );
+$art = $artist_rs->find( { name => 'some other name' }, { key => 'primary' } );
+ok( $art, 'Artist found by key in the resultset' );
+
Index: lib/DBIx/Class/ResultSet.pm
===================================================================
--- lib/DBIx/Class/ResultSet.pm (revision 4075)
+++ lib/DBIx/Class/ResultSet.pm (working copy)
@@ -392,7 +392,9 @@
my $alias = exists $attrs->{alias} ? $attrs->{alias} : $self->{attrs}{alias};
my $query = @unique_queries
? [ map { $self->_add_alias($_, $alias) } @unique_queries ]
- : $self->_add_alias($input_query, $alias);
+ : exists $attrs->{key}
+ ? {}
+ : $self->_add_alias($input_query, $alias);
# Run the query
if (keys %$attrs) {
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]