MSSQL/Diff/Schema.pm

filter: Statementstmt 97.3% 37 / 38 Branchbran 100% 8 / 8 Conditioncond 77.7% 7 / 9 MC/DCmcdc 60.0% 3 / 5 Subroutinesub 88.8% 8 / 9 Podpod 100% 3 / 3 totaltotal 91.6% 66 / 72 CC 12 SCAR 20.3
CC
12
Cov
95%
diff
12.1
__ANON__
1.0
__ANON__
1.0
CRAP 7.7
« MSSQL/Introspect/Indexes.pm ↑ Summary MSSQL/Deploy.pm »
1 package DBIO::MSSQL::Diff::Schema;
2 # ABSTRACT: Diff operations for MSSQL schemas
3  
4 36 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 36 our $VERSION = '0.900007';
8  
9 36 ▶use base 'DBIO::Diff::Op';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 36 ▶use DBIO::MSSQL::DDL qw(_quote_ident _schema_prefix);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 36 __PACKAGE__->mk_diff_accessors(qw/schema_name/);
15  
16  
17 94 ▶sub diff {
Subroutine diff: called CC=12 SCAR=24.9
Pod documented
18 94 my ($class, $source, $target) = @_;
19 94 my $coll = $source->{collation};
20 0 ▶ my $fold = $coll && !$coll->{case_sensitive} ? sub { lc $_[0] } : sub { $_[0] };
Subroutine __ANON__: not called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
$coll && !$coll->{'case_sensitive'} ? : 5 89 94
Condition100%3/3
$coll and not $coll->{"case_sensitive"}
!ll&&!rl&&r
8815
MC/DC100%2/2
$coll and not $coll->{"case_sensitive"}
$coll not $coll->{"case_sensitive"}
Truth table100%3/3
A and not(B)
A= $collB= not $coll->{"case_sensitive"}
ABresult
0X0
100
111
21  
22 94 my %have = (dbo => 1);
23 94 ▶ $have{ $fold->($_) } = 1 for keys %{ $source->{schemas} // {} };
Condition100%2/2
$source->{"schemas"} // {}
l!l
688
MC/DC100%1/1
$source->{"schemas"} // {}
$source->{"schemas"}
Truth table100%2/2
A
A= $source->{"schemas"}
Aresult
11
00
24 94 ▶ for my $name (keys %{ $source->{tables} // {} }) {
Condition50%1/2
$source->{"tables"} // {}
l!l
940
MC/DC0%0/1
$source->{"tables"} // {}
$source->{"tables"}
Truth table50%1/2
A
A= $source->{"tables"}
Aresult
11
00
25 128 ▶ $have{ $fold->($1) } = 1 if $name =~ /\A([^.]+)\./;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\A([^.]+)\./ 5 123 128
26 }
27  
28 94 my (%want);
29 94 ▶ my $tables = $target->{tables} // {};
Condition50%1/2
$target->{"tables"} // {}
l!l
940
MC/DC0%0/1
$target->{"tables"} // {}
$target->{"tables"}
Truth table50%1/2
A
A= $target->{"tables"}
Aresult
11
00
30 94 for my $name (keys %$tables) {
31 146 ▶ next unless $name =~ /\A([^.]+)\./;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /\A([^.]+)\./ 139 7 146
32 7 my $schema = $1;
33 7 ▶ $want{$schema} = 1 unless $have{ $fold->($schema) };
Branch: 1 branch
BranchTrueFalseTotal
unless $have{&$fold($schema)} 3 4 7
34 }
35 94 return map { $class->new(action => 'create', schema_name => $_) } sort keys %want;
36 }
37  
38  
39 2 ▶sub as_sql {
Subroutine as_sql: called CC=1 SCAR=0.0
Pod documented
40 2 my ($self) = @_;
41 2 return sprintf 'CREATE SCHEMA %s;', _quote_ident($self->schema_name);
42 }
43  
44  
45 1 ▶sub summary {
Subroutine summary: called CC=1 SCAR=0.0
Pod documented
46 1 my ($self) = @_;
47 1 return sprintf '%s schema: %s', $self->summary_prefix, $self->schema_name;
48 }
49  
50 36 1;
51  
52 __END__
« MSSQL/Introspect/Indexes.pm ↑ Summary MSSQL/Deploy.pm »