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