line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::Composer::Quoter; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
13047
|
use strict; |
|
10
|
|
|
|
|
10
|
|
|
10
|
|
|
|
|
217
|
|
4
|
10
|
|
|
10
|
|
27
|
use warnings; |
|
10
|
|
|
|
|
9
|
|
|
10
|
|
|
|
|
3261
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
87
|
|
|
87
|
0
|
8714
|
my $class = shift; |
8
|
87
|
|
|
|
|
164
|
my (%params) = @_; |
9
|
|
|
|
|
|
|
|
10
|
87
|
|
|
|
|
89
|
my $self = {}; |
11
|
87
|
|
|
|
|
88
|
bless $self, $class; |
12
|
|
|
|
|
|
|
|
13
|
87
|
|
100
|
|
|
384
|
$self->{quote_char} = $params{quote_char} ||= '`'; |
14
|
87
|
|
100
|
|
|
243
|
$self->{name_separator} = $params{name_separator} ||= '.'; |
15
|
87
|
|
50
|
|
|
219
|
$self->{quote_string_char} = $params{quote_string_char} ||= "'"; |
16
|
|
|
|
|
|
|
|
17
|
87
|
100
|
|
|
|
151
|
if (my $driver = $params{driver}) { |
18
|
5
|
100
|
|
|
|
28
|
if ($driver =~ /Pg/i) { |
19
|
2
|
|
|
|
|
4
|
$self->{quote_char} = '"'; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
87
|
|
|
|
|
281
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub quote { |
27
|
212
|
|
|
212
|
0
|
165
|
my $self = shift; |
28
|
212
|
|
|
|
|
187
|
my ($column, $prefix) = @_; |
29
|
|
|
|
|
|
|
|
30
|
212
|
|
|
|
|
596
|
my @parts = split /\Q$self->{name_separator}\E/, $column; |
31
|
212
|
|
|
|
|
230
|
foreach my $part (@parts) { |
32
|
221
|
|
|
|
|
295
|
$part = $self->{quote_char} . $part . $self->{quote_char}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
212
|
100
|
100
|
|
|
454
|
if ($prefix && @parts == 1) { |
36
|
80
|
|
|
|
|
111
|
unshift @parts, $self->{quote_char} . $prefix . $self->{quote_char}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
212
|
|
|
|
|
692
|
return join $self->{name_separator}, @parts; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub quote_string { |
43
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
44
|
2
|
|
|
|
|
3
|
my ($string) = @_; |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
15
|
$string =~ s{$self->{quote_string_char}}{\\$self->{quote_string_char}}g; |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
7
|
return $self->{quote_string_char} . $string . $self->{quote_string_char}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub split { |
52
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
53
|
2
|
|
|
|
|
2
|
my ($quoted_column) = @_; |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
14
|
my ($table, $column) = split /\Q$self->{name_separator}\E/, $quoted_column; |
56
|
2
|
100
|
|
|
|
5
|
($column, $table) = ($table, '') unless $column; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return |
59
|
2
|
|
|
|
|
3
|
map { s/^\Q$self->{quote_char}\E//; s/\Q$self->{quote_char}\E$//; $_ } |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
15
|
|
60
|
|
|
|
|
|
|
($table, $column); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |