Crop/Object/Warehouse/Lang/SQL/Query/Delete.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 47 CC 4 SCAR 17.0
CC
4
Cov
0%
print_sql
12.0
new
6.0
BEGIN
2.0
CRAP 5.5
1 package Crop::Object::Warehouse::Lang::SQL::Query::Delete;
2 use base qw/ Crop::Object::Warehouse::Lang::SQL::Query /;
3  
4 =begin nd
5 Class: Crop::Object::Warehouse::Lang::SQL::Query::Delete
6 The Delete query.
7 =cut
8  
9 use v5.14;
10 use warnings;
11  
12 use Crop::Error;
13 use Crop::Object::Warehouse::Lang::SQL::Clause;
14  
15 use Crop::Debug;
16  
17 =begin nd
18 Variable: our %Attributes
19 Class members:
20  
21 clause - exemplar of <Crop::Object::Warehouse::Lang::SQL::Clause>
22 table - table name
23 =cut
24 our %Attributes = (
25 clause => undef,
26 table => undef,
27 );
28  
29 =begin nd
30 Constructor: new ( )
31 Build clause.
32
33 Returns:
34 $self
35 =cut
36 sub new {
37 my ($class, %in) = @_;
38  
39 my @clause = ();
40 my $self = $class->SUPER::new(
41 %in,
42 exists $in{clause} ?
43 (clause => Crop::Object::Warehouse::Lang::SQL::Clause->new($in{clause}))
44 : ()
45 ,
46 );
47
48 $self;
49 }
50  
51 =begin nd
52 Method: print_sql ( )
53 Compose query prepared string based on inner presentation.
54
55 Returns:
56 the array of two elements, SQL string, and arrayref of values for placeholders
57 =cut
58 sub print_sql {
59 my $self = shift;
60
61 my $sql = "DELETE FROM $self->{table} ";
62  
63 my $values;
64 if ($self->{clause}) {
65 my $where;
66
67 ($where, $values) = $self->{clause}->print_sql;
68
69 $sql .= " WHERE $where " if $where;
70 }
71  
72 ($sql, $values);
73 }
74  
75 1;