line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ObjectDB::Quoter; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
35
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
145
|
|
4
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
202
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '3.28'; |
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
29
|
use base 'SQL::Composer::Quoter'; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
418
|
|
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
33
|
use List::Util qw(first); |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
1952
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
0
|
|
|
0
|
0
|
|
my $self = shift->SUPER::new(@_); |
14
|
0
|
|
|
|
|
|
my (%params) = @_; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
$self->{meta} = $params{meta}; |
17
|
0
|
|
|
|
|
|
$self->{with} = []; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
return $self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub quote { |
23
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
24
|
0
|
|
|
|
|
|
my ($column, $prefix) = @_; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my @parts = split /[.]/xsm, $column; |
27
|
0
|
|
|
|
|
|
$column = pop @parts; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $meta = $self->{meta}; |
30
|
0
|
|
|
|
|
|
my $rel_table; |
31
|
|
|
|
|
|
|
my $name; |
32
|
0
|
|
|
|
|
|
foreach my $part (@parts) { |
33
|
0
|
|
|
|
|
|
my $relationship = $meta->get_relationship($part); |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
$name = $name ? $name . '_' . $relationship->name : $relationship->name; |
36
|
0
|
|
|
|
|
|
$rel_table = $relationship->class->meta->table; |
37
|
0
|
|
|
|
|
|
$meta = $relationship->class->meta; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if ($rel_table) { |
41
|
0
|
|
|
|
|
|
$column = $name . q{.} . $column; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $with = join q{.}, @parts; |
44
|
0
|
|
|
|
|
|
push @{ $self->{with} }, $with |
45
|
0
|
0
|
|
0
|
|
|
unless first { $_ eq $with } @{ $self->{with} }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return $self->SUPER::quote($column, $prefix); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub with { |
52
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
return @{ $self->{with} || [] }; |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |