blib/lib/DBIO/PostgreSQL/Diff/CaseOnly.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 4 / 4 Conditioncond 100% 4 / 4 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 100% 49 / 49 CC 10 SCAR 17.5
CC
10
Cov
100%
pairs
8.0
refuse
3.0
BEGIN
1.0
CRAP 5.8
« blib/lib/DBIO/PostgreSQL/Storage.pm ↑ Summary blib/lib/DBIO/PostgreSQL/ResultSet.pm »
1 package DBIO::PostgreSQL::Diff::CaseOnly;
2 # ABSTRACT: A name that differs from one in the database only in case is not a new object
3  
4 111 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 111 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 111 our $VERSION = '0.900007';
8  
9  
10  
11 4247 ▶sub pairs {
Subroutine pairs: called CC=8 SCAR=20.8
Pod documented
12 4247 my ($class, $source, $target) = @_;
13  
14 # A name cannot hold a NUL byte, so nothing joined with one reads as
15 # another place.
16 4247 my (%source, %target);
17 4247 $source{ join "\0", @{ $_->{in} } }{ $_->{name} } = $_ for @$source;
18 4247 $target{ join "\0", @{ $_->{in} } }{ $_->{name} } = $_ for @$target;
19  
20 4247 my @pairs;
21 4247 for my $in (sort keys %target) {
22 851 ▶ my ($had, $wanted) = ($source{$in} // {}, $target{$in});
Condition100%2/2
$source{$in} // {}
l!l
76982
MC/DC100%1/1
$source{$in} // {}
$source{$in}
Truth table100%2/2
A
A= $source{$in}
Aresult
11
00
23  
24 851 my %gone;
25 851 push @{ $gone{ lc $_ } }, $_ for grep { !exists $wanted->{$_} } sort keys %$had;
26  
27 851 for my $new (sort grep { !exists $had->{$_} } keys %$wanted) {
28 175 ▶ push @pairs, map { [ $had->{$_}, $wanted->{$new} ] } @{ $gone{ lc $new } // [] };
Condition100%2/2
$gone{lc $new} // []
l!l
19156
MC/DC100%1/1
$gone{lc $new} // []
$gone{lc $new}
Truth table100%2/2
A
A= $gone{lc $new}
Aresult
11
00
29 }
30 }
31 4247 return @pairs;
32 }
33  
34  
35 7511 ▶sub refuse {
Subroutine refuse: called CC=3 SCAR=11.0
Pod documented
36 7511 my ($class, $would, $first, @more) = @_;
37 7511 ▶ return unless $first;
Branch: 1 branch
BranchTrueFalseTotal
unless $first 7497 14 7511
38  
39 die join "\n",
40 sprintf(
41 'refusing to diff: %s %s is in the database and %s in the target, and the two names differ only in upper and lower case',
42 14 ▶ @{$first}{qw( kind database target )},
Branch: 1 branch
BranchTrueFalseTotal
@more ? : 2 12 14
43 ),
44 ( @more
45 3 ? ( 'The same holds for:', map { " $_->{kind} $_->{database} and $_->{target}" } @more )
46 : () ),
47 '',
48 'PostgreSQL reads a name written without quotes in lower case and a quoted one',
49 'exactly, so one object is easily known under two spellings. The diff takes',
50 'them for two: it would create what the target names and drop what the',
51 'database has.',
52 $would,
53 'No statement was generated.',
54 '',
55 'Where the two are the same object, rename what the database has,',
56 14 ( map { " $_->{rename}" } $first, @more ),
57 'and diff again. Where they are not, drop what the database has yourself, or',
58 'give it another name, and diff again.',
59 '';
60 }
61  
62  
63 111 1;
64  
65 __END__
« blib/lib/DBIO/PostgreSQL/Storage.pm ↑ Summary blib/lib/DBIO/PostgreSQL/ResultSet.pm »