[Dbix-class] Re: Validating column data

Bill Moseley moseley at hank.org
Wed Feb 3 00:31:36 GMT 2010


Ok, here's a more specific question.  Is there a way to generate an empty
result set?
For example, I want to test the search criteria and return an "empty" result
set (or undef) if it fails the test.

I guess this is one way, but it will mean an unnecessary trip to the
database:

sub search_rs {
    my ($self, $criteria, @rest )  =3D @_;

    return $self->validate_criteria( $criteria )
        ? $self->next::method( $criteria, @rest )
        : $self->next::method( { 1 =3D> 0 } );
}


validate_criteria() is a bit ugly, but that's another story.





-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100202/3e8=
67e22/attachment.htm


More information about the DBIx-Class mailing list