[Dbix-class] Return value of DBIx::Class::ResultSet::find()

Christopher H. Laco claco at chrislaco.com
Tue May 15 21:36:02 GMT 2007


Bernhard Graf wrote:
> Matt S Trout wrote:
> =

>> On Sun, May 13, 2007 at 10:25:16PM +0200, Bernhard Graf wrote:
>>> So since find() is not designed to return lists, to be consistent
>>> it should always return a single value: either a row object or
>>> undef.
>>>
>>> Objections?
>> I'm now convinced.
>>
>> Patch and test please, if you get 'em in by the end of the week we
>> can try it for the 08 rc cycle and see if it breaks anybody's code.
> =

> Looking at the code brings me to this question:
> =

> Shouldn't next() and single() return undef instead of empty list for =

> "not found" too?

I could be wrong... but isn't there some magic in there to make things
like this DTRT instead of looping forever:


while (my $i =3D $parent->relname->next) {

};

instead of

my $children =3D $parent->relname;
while (my $i =3D $children->next) {

};


Maybe that's caching magic instead of empty list vs. undef scalar magic...

-=3DChris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070515/1c=
9424b5/signature.pgp


More information about the Dbix-class mailing list