DBomb/Query/Join.pm

filter: Statementstmt 62.2% 28 / 45 Branchbran 0.0% 0 / 4 Conditioncond 11.1% 1 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 5 totaltotal 45.5% 36 / 79 CC 6 SCAR 19.4
CC
6
Cov
50%
sql
20.0
using
6.0
on
2.1
CRAP 6.9
« DBomb/Query/GroupBy.pm ↑ Summary DBomb/Meta/HasQuery.pm »
1 package DBomb::Query::Join;
2  
3 =head1 NAME
4  
5 DBomb::Query::Join - Abstract a join between two DBomb sources.
6  
7  
8 =cut
9  
10 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 our $VERSION = '$Revision: 1.9 $';
13  
14 12 ▶use DBomb::Util qw(ctx_0);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 12 ▶use Carp::Assert;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 use Class::MethodMaker
17 12 ▶ 'new_with_init' => 'new',
Subroutine BEGIN: called CC=1 SCAR=0.0
18 'get_set' => [qw(left right type on_obj using_list)],
19 12 ;
20  
21 ## new Join($left, $right)
22 sub init
23 7 ▶{
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
24 7 my $self = shift;
25  
26 7 assert(@_ == 2, 'valid parameters');
27  
28 7 $self->left(shift);
29 7 $self->right(shift);
30 7 $self->type(''); ## inner
31 7 $self->on_obj(new DBomb::Query::Expr());
32 7 $self->using_list([]);
33 }
34  
35 sub sql
36 0 ▶{
Subroutine sql: not called CC=4 SCAR=30.0
Pod undocumented
37 0 my ($self, $dbh) = @_;
38 0 my $sql = $self->left->sql($dbh) . ' ' . $self->type . ' JOIN ' . $self->right;
39  
40 0 ▶ assert( $self->on_obj->is_not_empty || @{$self->using_list} > 0, "JOIN requires a USING clause or ON clause");
Condition0%0/3
$self->on_obj->is_not_empty || @{$self->using_list;} > 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->on_obj->is_not_empty || @{$self->using_list;} > 0
$self->on_obj->is_not_empty @{$self->using_list;} > 0
Truth table0%0/3
A || B
A= $self->on_obj->is_not_emptyB= @{$self->using_list;} > 0
ABresult
1X1
011
000
41  
42 0 ▶ if ($self->on_obj->is_not_empty){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->on_obj->is_not_empty) { } 0 0 0
43 0 my $on_sql = $self->on_obj->sql($dbh);
44 0 ▶ $sql .= " ON $on_sql " if length $on_sql;
Branch: 1 branch
BranchTrueFalseTotal
if length $on_sql 0 0 0
45 }
46 else{
47 0 $sql .= " USING ( ". join(',',@{$self->using_list}) .") ";
48 }
49 0 return ctx_0($sql);
50 }
51  
52 ## on(EXPR, @bind_values)
53 sub on
54 1 ▶{
Subroutine on: called CC=2 SCAR=7.4
Pod undocumented
55 1 my $self = shift;
56 1 ▶ assert(@_ && defined($_[0]), "on requires an EXPR");
Condition33%1/3
@_ && defined $_[0]
!ll&&!rl&&r
001
MC/DC0%0/2
@_ && defined $_[0]
@_ defined $_[0]
Truth table33%1/3
A && B
A= @_B= defined $_[0]
ABresult
0X0
100
111
57 1 $self->on_obj->append(@_);
58 1 return $self;
59 }
60  
61 ## using([columns...])
62 sub using
63 0 ▶{
Subroutine using: not called CC=2 SCAR=17.9
Pod undocumented
64 0 my $self = shift;
65 0 ▶ assert(@_ && defined($_[0]), "USING requires a list");
Condition0%0/3
@_ && defined $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@_ && defined $_[0]
@_ defined $_[0]
Truth table0%0/3
A && B
A= @_B= defined $_[0]
ABresult
0X0
100
111
66 0 push @{$self->using_list}, @_;
67 0 return $self;
68 }
69  
70 sub bind_values
71 0 ▶{
Subroutine bind_values: not called CC=1 SCAR=6.9
Pod undocumented
72 0 my $self = shift;
73 0 return $self->on_obj->bind_values;
74 }
75  
76 12 1;
77 __END__
« DBomb/Query/GroupBy.pm ↑ Summary DBomb/Meta/HasQuery.pm »