blib/lib/SQL/Composer/Delete.pm

filter: Statementstmt 100% 41 / 41 Branchbran 87.5% 7 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 4 totaltotal 86.5% 58 / 67 CC 6 SCAR 9.5
CC
6
Cov
94%
new
5.0
to_bind
2.1
BEGIN
1.0
CRAP 2.6
« blib/lib/SQL/Composer/Upsert.pm ↑ Summary blib/lib/SQL/Composer.pm »
1 package SQL::Composer::Delete;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 require Carp;
7 3 ▶use SQL::Composer::Quoter;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use SQL::Composer::Expression;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub new {
11 6 ▶ my $class = shift;
Subroutine new: called CC=5 SCAR=16.1
Pod undocumented
12 6 my (%params) = @_;
13  
14 6 my $self = { table => $params{from} };
15 6 bless $self, $class;
16  
17 $self->{quoter} =
18 6 ▶ $params{quoter} || SQL::Composer::Quoter->new(driver => $params{driver});
Condition33%1/3
$params{'quoter'} || 'SQL::Composer::Quoter'->new('driver', $params{'driver'})
l!l&&r!l&&!r
060
MC/DC0%0/2
$params{'quoter'} || 'SQL::Composer::Quoter'->new('driver', $params{'driver'})
$params{'quoter'} 'SQL::Composer::Quoter'->new('driver', $params{'driver'})
Truth table33%1/3
A || B
A= $params{'quoter'}B= 'SQL::Composer::Quoter'->new('driver', $params{'driver'})
ABresult
1X1
011
000
19  
20 6 my $sql = '';
21 6 my @bind;
22  
23 6 $sql .= 'DELETE FROM ';
24  
25 6 $sql .= $self->_quote($params{from});
26  
27 6 ▶ if ($params{where}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params{"where"}) 1 5 6
28 my $expr = SQL::Composer::Expression->new(
29 quoter => $self->{quoter},
30 expr => $params{where}
31 1 );
32 1 $sql .= ' WHERE ' . $expr->to_sql;
33 1 push @bind, $expr->to_bind;
34 }
35  
36 6 ▶ if (defined(my $limit = $params{limit})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $limit = $params{"limit"})) 2 4 6
37 2 $sql .= ' LIMIT ' . $limit;
38 }
39  
40 6 ▶ if (defined(my $offset = $params{offset})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $offset = $params{"offset"})) 1 5 6
41 1 $sql .= ' OFFSET ' . $offset;
42 }
43  
44 6 $self->{sql} = $sql;
45 6 $self->{bind} = \@bind;
46  
47 6 return $self;
48 }
49  
50 2 ▶sub table { shift->{table} }
Subroutine table: called CC=1 SCAR=0.0
Pod undocumented
51  
52 5 ▶sub to_sql { shift->{sql} }
Subroutine to_sql: called CC=1 SCAR=0.0
Pod undocumented
53 5 ▶sub to_bind { @{shift->{bind} || []} }
Subroutine to_bind: called CC=2 SCAR=7.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->{"bind"} or [] 0 5 5
54  
55 sub _quote {
56 6 ▶ my $self = shift;
Subroutine _quote: called CC=1 SCAR=0.0
57 6 my ($column) = @_;
58  
59 6 return $self->{quoter}->quote($column);
60 }
61  
62 3 1;
63 __END__
« blib/lib/SQL/Composer/Upsert.pm ↑ Summary blib/lib/SQL/Composer.pm »