[Dbix-class] rs->find finds by all columns

Ash Berlin ash_cpan at firemirror.com
Wed Jan 16 09:54:36 GMT 2008


On Jan 16, 2008, at 9:02 AM, Zbigniew Lukasiak wrote:

> Hi all
>
> This is a continuation of the "patch for ResultSet::find_or_new"
> thread - but it's also a subject on it's own.
>
> It is my understanding that:
>
> $schema->resultset("Artist")->find({name => 'Random Girl Band'}, {key
> => 'primary'});
>
> should never find anything - because it should search by the primary
> key that is not included in the search conditions.  And I believe I am
> not alone in this interpretation of the documentation - see for
> example Matt's words:
>
>> The usual use of find_or_new is to pass a unique key plus additional
>> attributes to be used for object creation (which are ignored in the  
>> find()
>> by specifying the key attr as well).
>
> But if there is a row with name == 'Random Girl Band' then it will
> find it.  To prove that I attach a patch for the  t/61findnot.t test.
>
> -- 
> Zbigniew Lukasiak
> http://brudnopis.blogspot.com/
> <61findnot.diff>_______________________________________________
>

Seems sensible to me - the patch shows the behaviour I would *expect*.

Ash




More information about the DBIx-Class mailing list