line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::OOP::Command; |
2
|
16
|
|
|
16
|
|
101
|
use strict; |
|
16
|
|
|
|
|
29
|
|
|
16
|
|
|
|
|
487
|
|
3
|
16
|
|
|
16
|
|
83
|
use warnings; |
|
16
|
|
|
|
|
22
|
|
|
16
|
|
|
|
|
586
|
|
4
|
16
|
|
|
16
|
|
74
|
use SQL::OOP::Base; |
|
16
|
|
|
|
|
24
|
|
|
16
|
|
|
|
|
332
|
|
5
|
16
|
|
|
16
|
|
1660
|
use SQL::OOP::ID; |
|
16
|
|
|
|
|
42
|
|
|
16
|
|
|
|
|
405
|
|
6
|
16
|
|
|
16
|
|
8215
|
use SQL::OOP::IDArray; |
|
16
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
471
|
|
7
|
16
|
|
|
16
|
|
92
|
use base qw(SQL::OOP::Array); |
|
16
|
|
|
|
|
25
|
|
|
16
|
|
|
|
|
8963
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
### --- |
10
|
|
|
|
|
|
|
### Constructor |
11
|
|
|
|
|
|
|
### --- |
12
|
|
|
|
|
|
|
sub new { |
13
|
60
|
|
|
60
|
1
|
120
|
my ($class, %args) = (@_); |
14
|
60
|
|
|
|
|
248
|
my $self = bless { |
15
|
|
|
|
|
|
|
gen => undef, |
16
|
|
|
|
|
|
|
array => undef, |
17
|
|
|
|
|
|
|
}, $class; |
18
|
|
|
|
|
|
|
|
19
|
60
|
|
|
|
|
239
|
$self->set(%args); |
20
|
60
|
|
|
|
|
186
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
### --- |
24
|
|
|
|
|
|
|
### Get Names of set arguments in array ref |
25
|
|
|
|
|
|
|
### --- |
26
|
0
|
|
|
0
|
1
|
0
|
sub KEYS { |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
### --- |
31
|
|
|
|
|
|
|
### Get prefixes for each clause in hash ref |
32
|
|
|
|
|
|
|
### --- |
33
|
0
|
|
|
0
|
1
|
0
|
sub PREFIXES { |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
### --- |
38
|
|
|
|
|
|
|
### Get clause names and array index in array |
39
|
|
|
|
|
|
|
### --- |
40
|
|
|
|
|
|
|
sub keys_to_idx { |
41
|
186
|
|
|
186
|
1
|
230
|
my ($self) = (@_); |
42
|
186
|
|
|
|
|
228
|
my $out = (); |
43
|
186
|
|
|
|
|
205
|
my $idx = 0; |
44
|
186
|
|
|
|
|
233
|
foreach my $key (@{$self->KEYS}) { |
|
186
|
|
|
|
|
483
|
|
45
|
1093
|
|
|
|
|
1600
|
$out->{$key} = $idx; |
46
|
1093
|
|
|
|
|
1328
|
$idx++; |
47
|
|
|
|
|
|
|
} |
48
|
186
|
|
|
|
|
531
|
return $out; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
### --- |
52
|
|
|
|
|
|
|
### Set elements |
53
|
|
|
|
|
|
|
### --- |
54
|
|
|
|
|
|
|
sub set { |
55
|
126
|
|
|
126
|
1
|
266
|
my ($self, %args) = @_; |
56
|
126
|
|
|
|
|
539
|
$self->_init_gen; |
57
|
126
|
|
|
|
|
357
|
my $tokens = $self->keys_to_idx; |
58
|
126
|
|
|
|
|
367
|
foreach my $key (keys %args) { |
59
|
144
|
|
|
|
|
227
|
my $idx = $tokens->{$key}; |
60
|
144
|
|
|
|
|
435
|
$self->{array}->[$idx] = SQL::OOP::Base->new($args{$key}); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
126
|
|
|
|
|
525
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
### --- |
67
|
|
|
|
|
|
|
### Genereate SQL snippet |
68
|
|
|
|
|
|
|
### --- |
69
|
|
|
|
|
|
|
sub generate { |
70
|
60
|
|
|
60
|
1
|
87
|
my ($self) = @_; |
71
|
60
|
|
|
|
|
108
|
$self->{gen} = ''; |
72
|
60
|
|
|
|
|
171
|
my $prefix = $self->PREFIXES; |
73
|
60
|
|
|
|
|
149
|
my $tokens = $self->keys_to_idx; |
74
|
60
|
|
|
|
|
115
|
for (my $idx = 0; $idx < @{$self->KEYS}; $idx++) { |
|
417
|
|
|
|
|
968
|
|
75
|
357
|
100
|
|
|
|
1165
|
if (my $obj = $self->{array}->[$idx]) { |
76
|
144
|
50
|
|
|
|
454
|
if (my $a = $obj->to_string) { |
77
|
144
|
100
|
|
|
|
813
|
if ($obj->isa(__PACKAGE__)) { |
78
|
3
|
|
|
|
|
10
|
$a = '('. $a. ')'; |
79
|
|
|
|
|
|
|
} |
80
|
144
|
|
|
|
|
360
|
my $name = $self->KEYS->[$idx]; |
81
|
144
|
100
|
|
|
|
477
|
if ($prefix->{$name}) { |
82
|
137
|
|
|
|
|
599
|
$self->{gen} .= ' '. $prefix->{$name}. ' '. $a; |
83
|
|
|
|
|
|
|
} else { |
84
|
7
|
|
|
|
|
26
|
$self->{gen} .= ' '. $a; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
60
|
|
|
|
|
516
|
$self->{gen} =~ s/^ //; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |