line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
### --- |
2
|
|
|
|
|
|
|
### Class for dot-chained Identifier ex) "public"."table"."colmun1" |
3
|
|
|
|
|
|
|
### --- |
4
|
|
|
|
|
|
|
package SQL::OOP::ID; |
5
|
19
|
|
|
19
|
|
91
|
use strict; |
|
19
|
|
|
|
|
31
|
|
|
19
|
|
|
|
|
606
|
|
6
|
19
|
|
|
19
|
|
95
|
use warnings; |
|
19
|
|
|
|
|
29
|
|
|
19
|
|
|
|
|
612
|
|
7
|
19
|
|
|
19
|
|
96
|
use base qw(SQL::OOP::Array); |
|
19
|
|
|
|
|
35
|
|
|
19
|
|
|
|
|
12398
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
### --- |
10
|
|
|
|
|
|
|
### Constructor |
11
|
|
|
|
|
|
|
### --- |
12
|
|
|
|
|
|
|
sub new { |
13
|
183
|
|
|
183
|
1
|
13976
|
my ($class, @array) = @_; |
14
|
183
|
|
|
|
|
758
|
return $class->SUPER::new(@array)->set_sepa('.'); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
### --- |
18
|
|
|
|
|
|
|
### Append ID |
19
|
|
|
|
|
|
|
### --- |
20
|
|
|
|
|
|
|
sub append { |
21
|
183
|
|
|
183
|
1
|
328
|
my ($self, @array) = @_; |
22
|
183
|
|
|
|
|
657
|
$self->_init_gen; |
23
|
183
|
100
|
100
|
|
|
571
|
if (ref $array[0] && ref $array[0] eq 'ARRAY') { |
24
|
12
|
|
|
|
|
17
|
@array = @{$array[0]}; |
|
12
|
|
|
|
|
35
|
|
25
|
|
|
|
|
|
|
} |
26
|
183
|
|
|
|
|
279
|
for my $elem (@array) { |
27
|
210
|
50
|
|
|
|
458
|
if ($elem) { |
28
|
210
|
|
|
|
|
218
|
push(@{$self->{array}}, SQL::OOP::ID::Parts->new($elem)); |
|
210
|
|
|
|
|
1047
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
183
|
|
|
|
|
967
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
### --- |
35
|
|
|
|
|
|
|
### "field AS foo" syntax |
36
|
|
|
|
|
|
|
### --- |
37
|
|
|
|
|
|
|
sub as { |
38
|
3
|
|
|
3
|
1
|
6
|
my ($self, $as) = (@_); |
39
|
3
|
|
|
|
|
9
|
$self->{as} = $as; |
40
|
3
|
|
|
|
|
12
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
### --- |
44
|
|
|
|
|
|
|
### Generate SQL snippet |
45
|
|
|
|
|
|
|
### --- |
46
|
|
|
|
|
|
|
sub generate { |
47
|
183
|
|
|
183
|
1
|
250
|
my $self = shift; |
48
|
183
|
|
|
|
|
217
|
my @array = map {$_->to_string} @{$self->{array}}; |
|
210
|
|
|
|
|
658
|
|
|
183
|
|
|
|
|
378
|
|
49
|
183
|
|
|
|
|
355
|
$self->{gen} = join($self->{sepa}, grep {$_} @array); |
|
210
|
|
|
|
|
554
|
|
50
|
|
|
|
|
|
|
|
51
|
183
|
100
|
|
|
|
399
|
if ($self->{as}) { |
52
|
3
|
|
|
|
|
29
|
$self->{gen} .= ' AS '. $self->quote($self->{as}); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
183
|
|
|
|
|
421
|
return $self; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
### --- |
59
|
|
|
|
|
|
|
### Class for Identifier such as table, field schema |
60
|
|
|
|
|
|
|
### --- |
61
|
|
|
|
|
|
|
package SQL::OOP::ID::Parts; |
62
|
19
|
|
|
19
|
|
124
|
use strict; |
|
19
|
|
|
|
|
31
|
|
|
19
|
|
|
|
|
646
|
|
63
|
19
|
|
|
19
|
|
88
|
use warnings; |
|
19
|
|
|
|
|
31
|
|
|
19
|
|
|
|
|
619
|
|
64
|
19
|
|
|
19
|
|
106
|
use base qw(SQL::OOP::Base); |
|
19
|
|
|
|
|
28
|
|
|
19
|
|
|
|
|
2713
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
### --- |
67
|
|
|
|
|
|
|
### Generate SQL snippet |
68
|
|
|
|
|
|
|
### --- |
69
|
|
|
|
|
|
|
sub generate { |
70
|
201
|
|
|
201
|
|
253
|
my $self = shift; |
71
|
201
|
|
|
|
|
685
|
$self->SUPER::generate(@_); |
72
|
201
|
|
|
|
|
691
|
$self->{gen} = $self->quote($self->{gen}); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |