| 1 | package # hide from PAUSE | ||||||||||||||||||||||||||||||||||||||||||
| 2 | DBIx::Class::CDBICompat::LazyLoading; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 0 | ▶ | sub resultset_instance { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resultset_instance: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | my $rs = $self->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | $rs = $rs->search(undef, { columns => [ $self->columns('Essential') ] }); | |||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | return $rs; | |||||||||||||||||||||||||||||||||||||||||
| 12 | } | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | # Emulate that CDBI throws out all changed columns and reloads them on | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # request in case the database modifies the new value (say, via a trigger) | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my @dirty_columns = keys %{$self->{_dirty_columns}}; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $ret = $self->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $self->_clear_column_data(@dirty_columns); | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | # And again for create | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my($data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my @columns = keys %$data; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $obj = $class->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return $obj unless defined $obj; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my %primary_cols = map { $_ => 1 } $class->primary_columns; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my @data_cols = grep !$primary_cols{$_}, @columns; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $obj->_clear_column_data(@data_cols); | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return $obj; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub _clear_column_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clear_column_data: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | delete $self->{_column_data}{$_} for @_; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | delete $self->{_inflated_column}{$_} for @_; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub get_column { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_column: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my ($self, $col) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if ((ref $self) && (!exists $self->{'_column_data'}{$col}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $self and not exists $self->{"_column_data"}{$col} and $self->{"_in_storage"}
ref $self and not exists $self->{"_column_data"}{$col}
MC/DC0%0/3
ref $self and not exists $self->{"_column_data"}{$col} and $self->{"_in_storage"}
ref $self
not exists $self->{"_column_data"}{$col}
$self->{"_in_storage"}
Truth table0%0/4
A and not(B) and C
A= ref $selfB= not exists $self->{"_column_data"}{$col}C= $self->{"_in_storage"}
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | && $self->{'_in_storage'}) { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | $self->_flesh(grep { exists $self->_column_groups->{$_}{$col} | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
exists $self->_column_groups->{$_}{$col} && $_ ne 'All'
MC/DC0%0/2
exists $self->_column_groups->{$_}{$col} && $_ ne 'All'
exists $self->_column_groups->{$_}{$col}
$_ ne 'All'
Truth table0%0/3
A && B
A= exists $self->_column_groups->{$_}{$col}B= $_ ne 'All'
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | && $_ ne 'All' } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | keys %{ $self->_column_groups || {} }); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_column_groups || {}
MC/DC0%0/1
$self->_column_groups || {}
$self->_column_groups
Truth table0%0/2
A
A= $self->_column_groups
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->next::method(@_[1..$#_]); | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | # CDBI does not explicitly declare auto increment columns, so | ||||||||||||||||||||||||||||||||||||||||||
| 67 | # we just clear out our primary columns before copying. | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub copy { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my($self, $changes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | for my $col ($self->primary_columns) { | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $changes->{$col} = undef unless exists $changes->{$col}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return $self->next::method($changes); | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub discard_changes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
discard_changes: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | delete $self->{_column_data}{$_} for $self->is_changed; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | delete $self->{_dirty_columns}; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | delete $self->{_relationship_data}; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub _ident_cond { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ident_cond: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return join(" AND ", map { "$_ = ?" } $class->primary_columns); | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub _flesh { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_flesh: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my ($self, @groups) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | @groups = ('All') unless @groups; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my %want; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $want{$_} = 1 for map { keys %{$self->_column_groups->{$_}} } @groups; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if (my @want = grep { !exists $self->{'_column_data'}{$_} } keys %want) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $cursor = $self->result_source->storage->select( | |||||||||||||||||||||||||||||||||||||||||
| 100 | $self->result_source->name, \@want, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | \$self->_ident_cond, { bind => [ $self->_ident_values ] }); | ||||||||||||||||||||||||||||||||||||||||||
| 102 | #my $sth = $self->storage->select($self->_table_name, \@want, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | # $self->ident_condition); | ||||||||||||||||||||||||||||||||||||||||||
| 104 | # Not sure why the first one works and this doesn't :( | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my @val = $cursor->next; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | return unless @val; # object must have been deleted from the database | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | foreach my $w (@want) { | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $self->{'_column_data'}{$w} = shift @val; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||