Mark Hedges wrote:
>>I don't think a database returning an empty result should throw an
>>exception, so checking for undef seems reasonable to me.
>>Adding an option to make an empty result be fatal might be possible, I
>>certainly wouldn't want it as the default behaviour.
> 
> The trouble is when I want to do $one->two->three->four and two 
> or three returns as undef because there is no value, then it 
> bombs.  An option would be nice. 

I have similar situations where I'd have a has-many relation where the
"many" table has a timestamp. Then I'l like to add a shortcut on

Artitst has_many Cd's.

$s->resultset("Artist")->lastcd();

That does just does

return $self->cds()->search({},{page => 1,rows => 1, order_by =>
"createtime desc"})->next();

Which fails horrible if there is no relation.... and I'd just like an
"undef" :-)

Anyway . it's just for convenience, adding af few more lines of code
solves the problem.

Jesper
-- 
Jesper Krogh, [EMAIL PROTECTED]


_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/

Reply via email to