blib/lib/SQL/Maker/Plugin/JoinSelect.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 87.5% 7 / 8 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 92.7% 51 / 55 CC 7 SCAR 15.8
CC
7
Cov
93%
join_select
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.8
↑ Summary
1 package SQL::Maker::Plugin::JoinSelect;
2 2 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our $VERSION = "0.03";
6  
7 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 our @EXPORT = qw/join_select/;
9  
10 8 ▶sub join_select {
Subroutine join_select: called CC=7 SCAR=19.5
Pod documented
11 8 my ($self, $base_table, $join_conditoins, $fields, $where, $opt) = @_;
12 8 my @join_conditions = @$join_conditoins;
13  
14 8 my @joins;
15 8 ▶ while ( my ($table, $join_cond) = splice @join_conditions, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@join_conditions, 0, 2)) 10 8 18
16 10 my ($type, $cond) = ('inner',);
17 10 my $ref = ref $join_cond;
18 10 ▶ if (!$ref || $ref eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (not $ref or $ref eq 'HASH') { } 3 7 10
elsif ($ref eq 'ARRAY') { } 7 0 7
Condition100%3/3
not $ref or $ref eq "HASH"
l!l&&r!l&&!r
217
MC/DC100%2/2
not $ref or $ref eq "HASH"
not $ref $ref eq "HASH"
Truth table100%3/3
not(A) or B
A= not $refB= $ref eq "HASH"
ABresult
1X1
011
000
19 3 $cond = $join_cond;
20 }
21 elsif ($ref eq 'ARRAY') {
22 7 ▶ if (uc($join_cond->[0]) =~ /^(?:(?:(?:LEFT|RIGHT|FULL)(?: OUTER)?)|INNER|CROSS)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (uc($join_cond->[0]) =~ /^(?:(?:(?:LEFT|RIGHT|FULL)(?: OUTER)?)|INNER|CROSS)$/) { } 5 2 7
23 5 $type = $join_cond->[0];
24 5 $cond = $join_cond->[1];
25 }
26 else {
27 2 $cond = $join_cond;
28 }
29 }
30 else {
31 0 Carp::croak 'join condition is not valid';
32 }
33  
34 10 push @joins, [$base_table => {
35 type => $type,
36 table => $table,
37 condition => $cond,
38 }];
39 }
40  
41 8 ▶ my %opt = %{ $opt || {} };
Condition50%1/2
$opt || {}
l!l
08
MC/DC0%0/1
$opt || {}
$opt
Truth table50%1/2
A
A= $opt
Aresult
11
00
42 8 push @{ $opt{joins} }, @joins;
43  
44 8 $self->select(undef, $fields, $where, \%opt);
45 }
46  
47 2 1;
48 __END__
↑ Summary