| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SQL::Translator::Generator::Role::Quote; |
|
2
|
|
|
|
|
|
|
|
|
3
|
23
|
|
|
23
|
|
49224
|
use Moo::Role; |
|
|
23
|
|
|
|
|
73
|
|
|
|
23
|
|
|
|
|
219
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
SQL::Translator::Generator::Role::Quote - Role for dealing with identifier |
|
8
|
|
|
|
|
|
|
quoting. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
I |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
requires qw(quote_chars name_sep); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has escape_char => ( |
|
19
|
|
|
|
|
|
|
is => 'ro', |
|
20
|
|
|
|
|
|
|
lazy => 1, |
|
21
|
|
|
|
|
|
|
clearer => 1, |
|
22
|
|
|
|
|
|
|
default => sub { $_[0]->quote_chars->[-1] }, |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub quote { |
|
26
|
1933
|
|
|
1933
|
0
|
18613
|
my ($self, $label) = @_; |
|
27
|
|
|
|
|
|
|
|
|
28
|
1933
|
50
|
|
|
|
4460
|
return '' unless defined $label; |
|
29
|
1933
|
50
|
|
|
|
4493
|
return $$label if ref($label) eq 'SCALAR'; |
|
30
|
|
|
|
|
|
|
|
|
31
|
1933
|
|
|
|
|
3091
|
my @quote_chars = @{$self->quote_chars}; |
|
|
1933
|
|
|
|
|
12337
|
|
|
32
|
1933
|
100
|
|
|
|
9952
|
return $label unless scalar @quote_chars; |
|
33
|
|
|
|
|
|
|
|
|
34
|
1209
|
|
|
|
|
2159
|
my ($l, $r); |
|
35
|
1209
|
50
|
|
|
|
3387
|
if (@quote_chars == 1) { |
|
|
|
50
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
($l, $r) = (@quote_chars) x 2; |
|
37
|
|
|
|
|
|
|
} elsif (@quote_chars == 2) { |
|
38
|
1209
|
|
|
|
|
2389
|
($l, $r) = @quote_chars; |
|
39
|
|
|
|
|
|
|
} else { |
|
40
|
0
|
|
|
|
|
0
|
die 'too many quote chars!'; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
1209
|
|
50
|
|
|
3564
|
my $sep = $self->name_sep || ''; |
|
44
|
1209
|
|
|
|
|
21889
|
my $esc = $self->escape_char; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# parts containing * are naturally unquoted |
|
47
|
1209
|
50
|
|
|
|
12250
|
join $sep, map { (my $n = $_) =~ s/\Q$r/$esc$r/g; "$l$n$r" } ( $sep ? split (/\Q$sep\E/, $label ) : $label ) |
|
|
1157
|
|
|
|
|
7484
|
|
|
|
1157
|
|
|
|
|
9906
|
|
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub quote_string { |
|
51
|
26
|
|
|
26
|
0
|
79
|
my ($self, $string) = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
26
|
50
|
|
|
|
75
|
return $string unless defined $string; |
|
54
|
26
|
|
|
|
|
75
|
$string =~ s/'/''/g; |
|
55
|
26
|
|
|
|
|
108
|
return qq{'$string'}; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHORS |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
See the included AUTHORS file: |
|
63
|
|
|
|
|
|
|
L |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Copyright (c) 2012 the SQL::Translator L as listed above. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 LICENSE |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This code is free software and may be distributed under the same terms as Perl |
|
72
|
|
|
|
|
|
|
itself. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |