| 1 | package DBIO::Diff::Base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Base class for DBIO driver diff orchestrators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 15 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 15 | our $CONTRACT_VERSION = '1.3'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | sub contract_version { $CONTRACT_VERSION } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contract_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 78 | ▶ | sub new { my ($class, %args) = @_; bless \%args, $class } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | sub diff_options { () } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diff_options: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | sub source { $_[0]->{source} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | sub target { $_[0]->{target} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
target: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 201 | ▶ | sub operations { $_[0]->{operations} //= $_[0]->_build_operations } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
operations: called CC=2 SCAR=6.9
Pod
documented
Condition100%3/3
$_[0]{"operations"} //= $_[0]->_build_operations
MC/DC100%2/2
$_[0]{"operations"} //= $_[0]->_build_operations
$_[0]{"operations"}
$_[0]->_build_operations
Truth table100%3/3
A //= B
A= $_[0]{"operations"}B= $_[0]->_build_operations
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | sub _build_operations { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_operations: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | die ref($self) . '::_build_operations not implemented'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 78 | ▶ | sub has_changes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_changes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 78 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 78 | return scalar @{ $self->operations } > 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 34 | ▶ | sub as_sql { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_sql: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 34 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 34 | return join "\n", map { $_->as_sql } @{ $self->operations }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | ▶ | sub summary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
summary: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | return join "\n", map { $_->summary } @{ $self->operations }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 60 | ▶ | sub classify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
classify: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 60 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 60 | my $ops = $self->operations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 60 | my %counts = (additive => 0, changing => 0, destructive => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 60 | my @refused; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 60 | for my $op (@$ops) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 101 | ▶ | my $action = $op->can('action') ? $op->action : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 101 | ▶ | $action //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$action //= ""
MC/DC100%1/1
$action //= ""
$action
Truth table100%2/2
A
A= $action
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 101 | ▶ | if ($action eq 'refuse') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 8 | push @refused, $op->summary; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ▶ | elsif ($action eq 'create' || $action eq 'add' || $action eq 'add_value') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$action eq "create" or $action eq "add" or $action eq "add_value"
$action eq "create" or $action eq "add"
MC/DC100%3/3
$action eq "create" or $action eq "add" or $action eq "add_value"
$action eq "create"
$action eq "add"
$action eq "add_value"
Truth table100%4/4
A or B or C
A= $action eq "create"B= $action eq "add"C= $action eq "add_value"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 27 | $counts{additive}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | elsif ($action eq 'drop') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 31 | ▶ | if (_op_is_destructive($op)) { $counts{destructive}++ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | else { $counts{changing}++ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 35 | $counts{changing}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 60 | ▶ | my $result = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | has_changes => (@$ops ? 1 : 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | class => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | counts => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | refused => \@refused, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 60 | ▶ | return $result if @refused; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 53 | my $class = 'none'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 53 | for my $c (qw(additive changing destructive)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 159 | ▶ | $class = $c if $counts{$c}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 53 | @$result{qw(class counts)} = ($class, \%counts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 53 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # A drop is destructive unless it is the first half of a drop plus create. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 43 | ▶ | sub _op_is_destructive { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_op_is_destructive: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 43 | my ($op) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 43 | ▶ | return !($op->can('replaced') && $op->replaced); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$op->can('replaced') && $op->replaced
MC/DC100%2/2
$op->can('replaced') && $op->replaced
$op->can('replaced')
$op->replaced
Truth table100%3/3
A && B
A= $op->can('replaced')B= $op->replaced
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 31 | ▶ | sub destructive_operations { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
destructive_operations: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 31 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | return grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 38 | my $op = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 38 | ▶ | my $action = $op->can('action') ? ($op->action // '') : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$op->action // ""
MC/DC0%0/1
$op->action // ""
$op->action
Truth table50%1/2
A
A= $op->action
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 38 | ▶ | ($action eq 'drop' && _op_is_destructive($op)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition88%8/9
$action eq 'drop' && _op_is_destructive($op) || $op->can('lossy') && $op->lossy
$action eq "drop" and _op_is_destructive($op)
$op->can("lossy") and $op->lossy
MC/DC75%3/4
$action eq 'drop' && _op_is_destructive($op) || $op->can('lossy') && $op->lossy
$action eq "drop"
_op_is_destructive($op)
$op->can("lossy")
$op->lossy
Truth table57%4/7
A and B || C and D
A= $action eq "drop"B= _op_is_destructive($op)C= $op->can("lossy")D= $op->lossy
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | || ($op->can('lossy') && $op->lossy) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 31 | } @{ $self->operations }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||