« lib/DBIx/Class/Helper/ResultSet/Shortcut/Search/NotBlankOrNull.pm
↑ Summary
lib/DBIx/Class/Helper/ResultSet/Shortcut/Search/Zero.pm »
| 1 | package DBIx::Class::Helper::ResultSet::Shortcut::Search::NullOrZero; | ||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | ▶ | use parent 'DBIx::Class::Helper::ResultSet::Shortcut::Search::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | sub null_or_zero { | ||||||||
|
Subroutine
null_or_zero: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 8 | 2 | my ( $self, @columns ) = @_; | |||||||||
| 9 | 2 | $self->load_components(qw{Helper::ResultSet::SetOperations}); | |||||||||
| 10 | 2 | ▶ | if ( !ref $columns[0] ) { # Only sent one column. This is easy. | ||||||||
|
Branch: 1 branch
| |||||||||||
| 11 | 1 | my $nulls_rs = $self->_helper_apply_search( { '=' => undef }, @columns ); | |||||||||
| 12 | 1 | my $not_empty_rs = $self->_helper_apply_search( { '=' => 0 }, @columns ); | |||||||||
| 13 | 1 | return $nulls_rs->union( [$not_empty_rs] ); | |||||||||
| 14 | } | ||||||||||
| 15 | else { | ||||||||||
| 16 | 1 | my @rs_array; | |||||||||
| 17 | 1 | my $i = 0; | |||||||||
| 18 | 1 | foreach my $column ( @{ $columns[0] } ) { | |||||||||
| 19 | 2 | my $nulls_rs = $self->_helper_apply_search( { '=' => undef }, $column ); | |||||||||
| 20 | 2 | my $not_empty_rs = $self->_helper_apply_search( { '=' => 0 }, $column ); | |||||||||
| 21 | 2 | $rs_array[$i] = $nulls_rs->union( [$not_empty_rs] ); | |||||||||
| 22 | 2 | $i++; | |||||||||
| 23 | } | ||||||||||
| 24 | 1 | my $result = shift @rs_array; | |||||||||
| 25 | 1 | return $result->intersect( \@rs_array ); | |||||||||
| 26 | } | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 5 | 1; | |||||||||
| 30 | |||||||||||
| 31 | __END__ | ||||||||||