line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::Composer::Delete; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
12721
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
70
|
|
4
|
3
|
|
|
3
|
|
9
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
69
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Carp; |
7
|
3
|
|
|
3
|
|
299
|
use SQL::Composer::Quoter; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
46
|
|
8
|
3
|
|
|
3
|
|
306
|
use SQL::Composer::Expression; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
703
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
6
|
|
|
6
|
0
|
3085
|
my $class = shift; |
12
|
6
|
|
|
|
|
16
|
my (%params) = @_; |
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
|
|
13
|
my $self = { table => $params{from} }; |
15
|
6
|
|
|
|
|
8
|
bless $self, $class; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$self->{quoter} = |
18
|
6
|
|
33
|
|
|
39
|
$params{quoter} || SQL::Composer::Quoter->new(driver => $params{driver}); |
19
|
|
|
|
|
|
|
|
20
|
6
|
|
|
|
|
9
|
my $sql = ''; |
21
|
6
|
|
|
|
|
7
|
my @bind; |
22
|
|
|
|
|
|
|
|
23
|
6
|
|
|
|
|
8
|
$sql .= 'DELETE FROM '; |
24
|
|
|
|
|
|
|
|
25
|
6
|
|
|
|
|
14
|
$sql .= $self->_quote($params{from}); |
26
|
|
|
|
|
|
|
|
27
|
6
|
100
|
|
|
|
16
|
if ($params{where}) { |
28
|
|
|
|
|
|
|
my $expr = SQL::Composer::Expression->new( |
29
|
|
|
|
|
|
|
quoter => $self->{quoter}, |
30
|
|
|
|
|
|
|
expr => $params{where} |
31
|
1
|
|
|
|
|
5
|
); |
32
|
1
|
|
|
|
|
2
|
$sql .= ' WHERE ' . $expr->to_sql; |
33
|
1
|
|
|
|
|
2
|
push @bind, $expr->to_bind; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
6
|
100
|
|
|
|
13
|
if (defined(my $limit = $params{limit})) { |
37
|
2
|
|
|
|
|
3
|
$sql .= ' LIMIT ' . $limit; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
6
|
100
|
|
|
|
13
|
if (defined(my $offset = $params{offset})) { |
41
|
1
|
|
|
|
|
2
|
$sql .= ' OFFSET ' . $offset; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
6
|
$self->{sql} = $sql; |
45
|
6
|
|
|
|
|
9
|
$self->{bind} = \@bind; |
46
|
|
|
|
|
|
|
|
47
|
6
|
|
|
|
|
11
|
return $self; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
2
|
0
|
698
|
sub table { shift->{table} } |
51
|
|
|
|
|
|
|
|
52
|
5
|
|
|
5
|
0
|
16
|
sub to_sql { shift->{sql} } |
53
|
5
|
50
|
|
5
|
0
|
1343
|
sub to_bind { @{shift->{bind} || []} } |
|
5
|
|
|
|
|
20
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _quote { |
56
|
6
|
|
|
6
|
|
6
|
my $self = shift; |
57
|
6
|
|
|
|
|
6
|
my ($column) = @_; |
58
|
|
|
|
|
|
|
|
59
|
6
|
|
|
|
|
15
|
return $self->{quoter}->quote($column); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |