| 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
| |||||||||||||||||||||||||||||||||
| 16 | 10 | my ($type, $cond) = ('inner',); | |||||||||||||||||||||||||||||||
| 17 | 10 | my $ref = ref $join_cond; | |||||||||||||||||||||||||||||||
| 18 | 10 | ▶ | if (!$ref || $ref eq 'HASH') { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
not $ref or $ref eq "HASH"
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"
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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 || {}
MC/DC0%0/1
$opt || {}
$opt
Truth table50%1/2
A
A= $opt
| |||||||||||||||||||||||||||||||||
| 42 | 8 | push @{ $opt{joins} }, @joins; | |||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 8 | $self->select(undef, $fields, $where, \%opt); | |||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 2 | 1; | |||||||||||||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||||||||||||||