line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::Composer::Join; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
13205
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
88
|
|
4
|
4
|
|
|
4
|
|
15
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
96
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Carp; |
7
|
4
|
|
|
4
|
|
1444
|
use SQL::Composer::Quoter; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
107
|
|
8
|
4
|
|
|
4
|
|
1228
|
use SQL::Composer::Expression; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
963
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
15
|
|
|
15
|
0
|
6777
|
my $class = shift; |
12
|
15
|
|
|
|
|
48
|
my (%params) = @_; |
13
|
|
|
|
|
|
|
|
14
|
15
|
|
|
|
|
27
|
my $self = {}; |
15
|
15
|
|
|
|
|
28
|
bless $self, $class; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$self->{quoter} = $params{quoter} |
18
|
|
|
|
|
|
|
|| SQL::Composer::Quoter->new( |
19
|
|
|
|
|
|
|
driver => $params{driver}, |
20
|
|
|
|
|
|
|
default_prefix => $params{as} || $params{source} |
21
|
15
|
|
66
|
|
|
72
|
); |
22
|
|
|
|
|
|
|
|
23
|
15
|
|
|
|
|
24
|
my $sql = ''; |
24
|
15
|
|
|
|
|
22
|
my @bind; |
25
|
|
|
|
|
|
|
|
26
|
15
|
100
|
|
|
|
40
|
$sql .= uc($params{op}) . ' ' if $params{op}; |
27
|
15
|
|
|
|
|
23
|
$sql .= 'JOIN '; |
28
|
|
|
|
|
|
|
|
29
|
15
|
|
|
|
|
39
|
$sql .= $self->_quote($params{source}) . ' '; |
30
|
|
|
|
|
|
|
|
31
|
15
|
100
|
|
|
|
42
|
if (my $as = $params{as}) { |
32
|
7
|
|
|
|
|
18
|
$sql .= 'AS ' . $self->_quote($as) . ' '; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
15
|
100
|
|
|
|
40
|
if (my $constraint = $params{on}) { |
|
|
50
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $expr = SQL::Composer::Expression->new( |
37
|
|
|
|
|
|
|
default_prefix => $params{as} || $params{source}, |
38
|
|
|
|
|
|
|
quoter => $self->{quoter}, |
39
|
14
|
|
66
|
|
|
76
|
expr => $constraint |
40
|
|
|
|
|
|
|
); |
41
|
14
|
|
|
|
|
37
|
$sql .= 'ON ' . $expr->to_sql; |
42
|
14
|
|
|
|
|
37
|
push @bind, $expr->to_bind; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif (my $column = $params{using}) { |
45
|
1
|
|
|
|
|
3
|
$sql .= 'USING ' . $self->_quote($column); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
15
|
|
|
|
|
31
|
$self->{sql} = $sql; |
49
|
15
|
|
|
|
|
29
|
$self->{bind} = \@bind; |
50
|
|
|
|
|
|
|
|
51
|
15
|
|
|
|
|
41
|
return $self; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
15
|
|
|
15
|
0
|
48
|
sub to_sql { shift->{sql} } |
55
|
15
|
50
|
|
15
|
0
|
1947
|
sub to_bind { @{shift->{bind} || []} } |
|
15
|
|
|
|
|
63
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _quote { |
58
|
23
|
|
|
23
|
|
35
|
my $self = shift; |
59
|
23
|
|
|
|
|
36
|
my ($column) = @_; |
60
|
|
|
|
|
|
|
|
61
|
23
|
|
|
|
|
57
|
return $self->{quoter}->quote($column); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |