| 1 | package DBIx::Class::ResultSet::BitField; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 4 | our $VERSION = '0.13'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use base 'DBIx::Class::ResultSet'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | sub search_bitfield { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_bitfield: called CC=11 SCAR=34.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | my ($self, $search) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_bitfield: not called CC=11 SCAR=34.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my $source = $self->result_source; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $row = $self->new_result({}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | my %search = ref $search eq 'ARRAY' ? @{$search} : ref $search eq 'HASH' ? %{$search} : croak 'search_bitfield takes an arrayref or a hashref'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my $type = ref $search eq 'ARRAY' ? '-or' : '-and'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $query = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | while(my($column, $value) = each %search) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | $column =~ s/^(.*?\.)?(.*)$/$2/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my $prefix = $1 || q{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
$1 || ''
$1 || ''
MC/DC0%0/1
$1 || ''
$1
MC/DC0%0/1
$1 || ''
$1
Truth table0%0/2
A
A= $1
Truth table50%1/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | next unless(my $bitfield = $row->__is_bitfield_item($column)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $info = $source->column_info($bitfield); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | foreach my $field (@{$info->{bitfield} || []}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
$info->{'bitfield'} || []
$info->{'bitfield'} || []
MC/DC0%0/1
$info->{'bitfield'} || []
$info->{'bitfield'}
MC/DC0%0/1
$info->{'bitfield'} || []
$info->{'bitfield'}
Truth table0%0/2
A
A= $info->{'bitfield'}
Truth table50%1/2
A
A= $info->{'bitfield'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $bit = 2**$i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | next unless($field eq $column); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if($value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | push(@{$query}, \qq($prefix$bitfield & $bit > 0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | push(@{$query}, \qq($prefix$bitfield & $bit = 0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | return $self->search({ $type => $query }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: called CC=11 SCAR=37.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my ($self, $data, @rest) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=11 SCAR=37.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $source = $self->result_source; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $row = $self->new_result({}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | while(my ($k, $value) = each %{$data || {}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition25%1/4
$data || {}
$data || {}
MC/DC0%0/1
$data || {}
$data
MC/DC0%0/1
$data || {}
$data
Truth table0%0/2
A
A= $data
Truth table50%1/2
A
A= $data
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $info = $source->column_info($k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if($row->__is_bitfield($info) && ($value !~ /^\d+$/ || int($value) ne $value)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%4/12
$row->__is_bitfield($info) and !($value =~ /^\d+$/) || int $value ne $value
not $value =~ /^\d+$/ or int $value ne $value
$row->__is_bitfield($info) and !($value =~ /^\d+$/) || int $value ne $value
not $value =~ /^\d+$/ or int $value ne $value
MC/DC0%0/3
$row->__is_bitfield($info) and !($value =~ /^\d+$/) || int $value ne $value
$row->__is_bitfield($info)
not $value =~ /^\d+$/
int $value ne $value
MC/DC33%1/3
$row->__is_bitfield($info) and !($value =~ /^\d+$/) || int $value ne $value
$row->__is_bitfield($info)
not $value =~ /^\d+$/
int $value ne $value
Truth table0%0/4
A and not(B) or C
A= $row->__is_bitfield($info)B= not $value =~ /^\d+$/C= int $value ne $value
Truth table50%2/4
A and not(B) or C
A= $row->__is_bitfield($info)B= not $value =~ /^\d+$/C= int $value ne $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if(ref $value eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | foreach my $bit (@{$value || []}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
$value || []
$value || []
MC/DC0%0/1
$value || []
$value
MC/DC0%0/1
$value || []
$value
Truth table0%0/2
A
A= $value
Truth table50%1/2
A
A= $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | $row->can($bit) ? $row->$bit(1) : croak qq(bitfield item '$bit' does not exist); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $row->can($value) ? $row->$value(1) : croak qq(bitfield item '$value' does not exist); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $accessor = $info->{accessor}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $data->{$k} = $row->$accessor; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $row = $self->new_result({}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | return $self->next::method($data, @rest); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||