NAME

DBIx::Class::Helper::ResultSet::MoreShortcuts - Additional shortcuts to common searches (->blank, ->is, etc)

VERSION

version 1.0001

SYNOPSIS

   # To apply to a specific ResultSet:
   package MyApp::Schema::ResultSet::Foo;
   
   __PACKAGE__->load_components(qw{Helper::ResultSet::MoreShortcuts});
   
   ...
   
   1;
   
   # Or, to apply to the entire schema:
   package MyApp::Schema;
   __PACKAGE__->load_namespaces( default_resultset_class => 'ResultSet' );

   1;

   package MyApp::Schema::ResultSet;
    
   __PACKAGE__->load_components(qw{Helper::ResultSet::MoreShortcuts});
    
   1;

   # And then elsewhere:
   my $foo_rs = $schema->resulset('Foo')->blank('column');

   # Both of these columns must be true:
   my $check_rs = $schema->resultset('Foo')->is(['active', 'ready_to_ship']);

DESCRIPTION

This helper set provides even more convenience methods for resultset selections. In all cases where you can send a list of fields, all of the fields must match the value, except in the case of is_any.

blank

$foo_rs->blank('field');
$foo_rs->blank(['field1','field2']);

not_blank

$foo_rs->not_blank('field');
$foo_rs->not_blank(['field1','field2']);

blank_or_null

$foo_rs->blank_or_null('field');
$foo_rs->blank_or_null(['field1','field2']);

not_blank_or_null

$foo_rs->not_blank_or_null('field');
$foo_rs->not_blank_or_null(['field1','field2']);

is

$foo_rs->is('boolean_field');
$foo_rs->is(['boolean_field1','boolean_field2']);

is_not

$foo_rs->is_not('boolean_field');
$foo_rs->is_not(['boolean_field1','boolean_field2']);

is_any

$foo_rs->is_any(['boolean_field1','boolean_field2']);

zero

$foo_rs->zero('numeric_field');
$foo_rs->zero(['numeric_field1', 'numeric_field2']);

null_or_zero

$foo_rs->null_or_zero('numeric_field');
$foo_rs->null_or_zero(['numeric_field1', 'numeric_field2']);

nonzero

$foo_rs->nonzero('numeric_field');
$foo_rs->nonzero(['numeric_field1', 'numeric_field2']);

positive

$foo_rs->positive('numeric_field');
$foo_rs->positive(['numeric_field1', 'numeric_field2']);

negative

$foo_rs->negative('numeric_field');
$foo_rs->negative(['numeric_field1', 'numeric_field2']);

ROADMAP

  • None of these are really doing much checking on their inputs. Oughta fix that and throw exceptions.

SEE ALSO

This component is actually a number of other components put together in a tidy bundle. It is entirely probable that more will be added. You can use the individual ones, if you like:

AUTHOR

D Ruth Holloway <ruth@hiruthie.me>

COPYRIGHT AND LICENSE

This software is copyright (c) 2023 by D Ruth Holloway.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.