| 1 | package DBIx::Class::Schema::Diff::Role::Common; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Types::Standard qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use List::MoreUtils qw(uniq); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Array::Diff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use JSON::DWIW; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Path::Class qw(file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 30 | ▶ | sub _types_list { qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_types_list: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | relationships | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | constraints | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | table_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | isa | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # Adapted from Hash::Diff, but heavily modified and specific to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # the unique needs of this module... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | sub _info_diff { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 7953 | ▶ | my ($self, $old, $new) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_info_diff: called CC=9 SCAR=22.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 7953 | my %old_keys = map {$_=>1} keys %$old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 7953 | my $nh = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 7953 | for my $k (keys %$new) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 24189 | ▶ | if (exists $old->{$k}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 24189 | delete $old_keys{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 24189 | ▶ | if(ref $new->{$k} eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3795 | ▶ | if(ref $old->{$k} eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 3795 | ▶ | my $diff = $self->_info_diff($old->{$k},$new->{$k}) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 22 | $nh->{$k} = $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $nh->{$k} = $new->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # Test if the non hash values are determined to be "equal" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 20394 | ▶ | $nh->{$k} = $new->{$k} unless ($self->_is_eq($old->{$k},$new->{$k})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $nh->{$k} = $new->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # fill back in any left over, old keys (i.e. weren't in $new): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # TODO: track these separately | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 7953 | $nh->{$_} = $old->{$_} for (keys %old_keys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 7953 | ▶ | return undef unless (keys %$nh > 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 90 | return $nh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # test non-hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # Note: since 'SchemaData' was introduced (Github Issue #1) most of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # this logic is now redundant/not needed... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | sub _is_eq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 21472 | ▶ | my ($self, $old, $new) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_eq: called CC=24 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # if both undef, they are equal: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 21472 | ▶ | return 1 if(!defined $old && !defined $new); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $old or defined $new
MC/DC0%0/2
defined $old or defined $new
defined $old
defined $new
Truth table33%1/3
A or B
A= defined $oldB= defined $new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 21472 | my ($o_ref,$n_ref) = (ref $old,ref $new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # one is a ref and the other isn't, obviously not equal: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 21472 | ▶ | return 0 if ($n_ref && !$o_ref || $o_ref && !$n_ref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
$n_ref and not $o_ref or $o_ref and not $n_ref
$n_ref and not $o_ref
$o_ref and not $n_ref
MC/DC0%0/4
$n_ref and not $o_ref or $o_ref and not $n_ref
$n_ref
not $o_ref
$o_ref
not $n_ref
Truth table28%2/7
A and not(B) or C and not(D)
A= $n_refB= not $o_refC= $o_refD= not $n_ref
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # both refs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 21472 | ▶ | if($o_ref && $n_ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$o_ref and $n_ref
MC/DC50%1/2
$o_ref and $n_ref
$o_ref
$n_ref
Truth table66%2/3
A and B
A= $o_refB= $n_ref
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # If they are not the same kind of ref, they obviously aren't equal: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 605 | ▶ | return 0 unless ($o_ref eq $n_ref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 605 | ▶ | if($n_ref eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # We can't tell the difference between CodeRefs, but we don't want | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # those cases to show up as changed, so we call them equal: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ▶ | elsif($n_ref eq 'SCALAR' || $n_ref eq 'REF') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$n_ref eq "SCALAR" or $n_ref eq "REF"
MC/DC0%0/2
$n_ref eq "SCALAR" or $n_ref eq "REF"
$n_ref eq "SCALAR"
$n_ref eq "REF"
Truth table33%1/3
A or B
A= $n_ref eq "SCALAR"B= $n_ref eq "REF"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # For ScalarRefs, compare their referants: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | return $self->_is_eq($$old,$$new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | elsif($n_ref eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # If they don't have the same number of elements, they aren't equal: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 605 | ▶ | return 0 unless (scalar @$new == scalar @$old); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # If they are both empty, they are equal: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 594 | ▶ | return 1 if (scalar @$new == 0 && scalar @$old == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
scalar @$new == 0 and scalar @$old == 0
MC/DC0%0/2
scalar @$new == 0 and scalar @$old == 0
scalar @$new == 0
scalar @$old == 0
Truth table33%1/3
A and B
A= scalar @$new == 0B= scalar @$old == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # iterate both sides: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 594 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 594 | for my $n_el (@$new) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1078 | my $o_el = $old->[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # Return 0 as soon as the first element is not equal: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1078 | ▶ | return 0 unless ($self->_is_eq($o_el,$n_el)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # If we made it here, then all the elements were equal above: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 572 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | elsif($n_ref eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # This case will only be called by us for HashRef elements of ArrayRef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # (case above). The main _info_diff() function handles HashRef's itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # Also note that from this point it is a true/false equality -- there | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # is no more selective merging of hashes, showing only different keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # If the hashes are equal, the diff should be undef: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | return $self->_info_diff($old,$new) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | elsif(blessed $new) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # If this is an object reference, just compare the classes, since we don't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # know how to compare object data and won't try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return $self->_is_eq(blessed($old),blessed($new)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | die "Unexpected ref type '$n_ref'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # simple scalar value comparison: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 20867 | ▶ | return (defined $old && defined $new && "$old" eq "$new"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
defined $old && defined $new && "$old" eq "$new"
defined $old and defined $new
MC/DC33%1/3
defined $old && defined $new && "$old" eq "$new"
defined $old
defined $new
"$old" eq "$new"
Truth table50%2/4
A and B && C
A= defined $oldB= defined $newC= "$old" eq "$new"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | sub _coerce_list_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | $_[0] && ! ref($_[0]) ? { $_[0] => 1 } : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 7 | ▶ | ref($_[0]) eq 'ARRAY' ? { map {$_=>1} @{$_[0]} } : $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coerce_list_hash: called CC=4 SCAR=13.9
Branch: 2 branches
Condition66%2/3
$_[0] and not ref $_[0]
MC/DC50%1/2
$_[0] and not ref $_[0]
$_[0]
not ref $_[0]
Truth table66%2/3
A and not(B)
A= $_[0]B= not ref $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | sub _coerce_schema_diff { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 89 | ▶ | blessed $_[0] ? $_[0] : DBIx::Class::Schema::Diff::Schema->new($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coerce_schema_diff: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | sub _coerce_schema_data { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 48 | ▶ | my ($v) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coerce_schema_data: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 48 | my $rt = ref($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 48 | ▶ | if($rt) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 32 | ▶ | if(blessed($v) && blessed($v) eq 'DBIx::Class::Schema::Diff::SchemaData') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
builtin::blessed($v) and builtin::blessed($v) eq "DBIx::Class::Schema::Diff::SchemaData"
MC/DC100%2/2
builtin::blessed($v) and builtin::blessed($v) eq "DBIx::Class::Schema::Diff::SchemaData"
builtin::blessed($v)
builtin::blessed($v) eq "DBIx::Class::Schema::Diff::SchemaData"
Truth table100%3/3
A and B
A= builtin::blessed($v)B= builtin::blessed($v) eq "DBIx::Class::Schema::Diff::SchemaData"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | return $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | elsif($rt eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | return DBIx::Class::Schema::Diff::SchemaData->new({ data => $v }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # Assume all other ref types are schema instances: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 29 | return DBIx::Class::Schema::Diff::SchemaData->new({ schema => $v }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 16 | ▶ | unless(Module::Runtime::is_module_name($v)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 4 | my $file = file($v)->absolute; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 | ▶ | if(-f $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # Assume it is a json file and try to decode it: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 4 | my $data = JSON::DWIW::deserialize_file($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 4 | return DBIx::Class::Schema::Diff::SchemaData->new({ data => $data }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 12 | return DBIx::Class::Schema::Diff::SchemaData->new({ schema => $v }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||