line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::Statement::Util; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
###################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# This module is copyright (c), 2001,2005 by Jeff Zucker. |
6
|
|
|
|
|
|
|
# This module is copyright (c), 2007-2020 by Jens Rehsack. |
7
|
|
|
|
|
|
|
# All rights reserved. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# It may be freely distributed under the same terms as Perl itself. |
10
|
|
|
|
|
|
|
# See below for help and copyright information (search for SYNOPSIS). |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
###################################################################### |
13
|
|
|
|
|
|
|
|
14
|
16
|
|
|
16
|
|
115
|
use strict; |
|
16
|
|
|
|
|
36
|
|
|
16
|
|
|
|
|
626
|
|
15
|
16
|
|
|
16
|
|
91
|
use warnings FATAL => "all"; |
|
16
|
|
|
|
|
38
|
|
|
16
|
|
|
|
|
750
|
|
16
|
|
|
|
|
|
|
|
17
|
16
|
|
|
16
|
|
116
|
use vars qw($VERSION); |
|
16
|
|
|
|
|
57
|
|
|
16
|
|
|
|
|
2052
|
|
18
|
|
|
|
|
|
|
$VERSION = '1.413_001'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub type |
21
|
|
|
|
|
|
|
{ |
22
|
2
|
|
|
2
|
1
|
19
|
my ($self) = @_; |
23
|
2
|
100
|
|
|
|
18
|
return 'function' if $self->isa('SQL::Statement::Util::Function'); |
24
|
1
|
50
|
|
|
|
9
|
return 'column' if $self->isa('SQL::Statement::Util::Column'); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
package SQL::Statement::Util::Column; |
28
|
|
|
|
|
|
|
|
29
|
16
|
|
|
16
|
|
120
|
use vars qw(@ISA); |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
970
|
|
30
|
|
|
|
|
|
|
@ISA = qw(SQL::Statement::Util); |
31
|
|
|
|
|
|
|
|
32
|
16
|
|
|
16
|
|
127
|
use Params::Util qw(_ARRAY _HASH0 _STRING); |
|
16
|
|
|
|
|
69
|
|
|
16
|
|
|
|
|
7171
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new |
35
|
|
|
|
|
|
|
{ |
36
|
1127
|
|
|
1127
|
|
2736
|
my ( $class, $col_name, $table_name, $term, $display_name, $full_orig_name, $coldef ) = @_; |
37
|
1127
|
|
66
|
|
|
2217
|
$display_name ||= $col_name; |
38
|
|
|
|
|
|
|
|
39
|
1127
|
100
|
66
|
|
|
6142
|
if ( $col_name && ( $col_name =~ m/^((?:"[^"]+")|(?:[^.]*))\.(.*)$/ ) ) |
|
|
50
|
33
|
|
|
|
|
40
|
|
|
|
|
|
|
{ |
41
|
20
|
|
|
|
|
73
|
$table_name = $1; |
42
|
20
|
|
|
|
|
53
|
$col_name = $2; |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
0
|
elsif ( defined( _ARRAY($table_name) ) && ( scalar( @{$table_name} ) == 1 ) ) |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
|
|
0
|
$table_name = $table_name->[0]; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
1127
|
|
|
|
|
4835
|
my %instance = ( |
50
|
|
|
|
|
|
|
name => $col_name, |
51
|
|
|
|
|
|
|
table => $table_name, |
52
|
|
|
|
|
|
|
display_name => $display_name, |
53
|
|
|
|
|
|
|
term => $term, |
54
|
|
|
|
|
|
|
full_orig_name => $full_orig_name, |
55
|
|
|
|
|
|
|
coldef => $coldef, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
1127
|
|
|
|
|
2179
|
my $self = bless( \%instance, $class ); |
59
|
|
|
|
|
|
|
|
60
|
1127
|
|
|
|
|
2810
|
return $self; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
21262
|
|
|
21262
|
|
43188
|
sub value($) { $_[0]->{term}->value( $_[1] ); } |
64
|
0
|
|
|
0
|
|
0
|
sub term() { $_[0]->{term} } |
65
|
13748
|
|
|
13748
|
|
40606
|
sub display_name() { $_[0]->{display_name} } |
66
|
0
|
|
|
0
|
|
0
|
sub full_orig_name() { $_[0]->{full_orig_name} } |
67
|
13283
|
|
|
13283
|
|
34576
|
sub name() { $_[0]->{name} } |
68
|
496
|
|
|
496
|
|
1368
|
sub table() { $_[0]->{table} } |
69
|
0
|
|
|
0
|
|
0
|
sub coldef() { $_[0]->{coldef} } |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
package SQL::Statement::Util::Function; |
72
|
|
|
|
|
|
|
|
73
|
16
|
|
|
16
|
|
133
|
use vars qw(@ISA); |
|
16
|
|
|
|
|
37
|
|
|
16
|
|
|
|
|
7261
|
|
74
|
|
|
|
|
|
|
@ISA = qw(SQL::Statement::Util); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub new |
77
|
|
|
|
|
|
|
{ |
78
|
2
|
|
|
2
|
|
558
|
my ( $class, $name, $sub_name, $args ) = @_; |
79
|
2
|
|
|
|
|
11
|
my ( $pkg, $sub ) = $sub_name =~ /^(.*::)([^:]+$)/; |
80
|
2
|
100
|
|
|
|
8
|
if ( !$sub ) |
81
|
|
|
|
|
|
|
{ |
82
|
1
|
|
|
|
|
2
|
$pkg = 'main'; |
83
|
1
|
|
|
|
|
3
|
$sub = $sub_name; |
84
|
|
|
|
|
|
|
} |
85
|
2
|
50
|
|
|
|
7
|
$pkg = 'main' if $pkg eq '::'; |
86
|
2
|
|
|
|
|
7
|
$pkg =~ s/::$//; |
87
|
2
|
|
|
|
|
11
|
my %newfunc = ( |
88
|
|
|
|
|
|
|
name => $name, |
89
|
|
|
|
|
|
|
sub_name => $sub, |
90
|
|
|
|
|
|
|
pkg_name => $pkg, |
91
|
|
|
|
|
|
|
args => $args, |
92
|
|
|
|
|
|
|
type => 'function', |
93
|
|
|
|
|
|
|
); |
94
|
2
|
|
|
|
|
15
|
return bless \%newfunc, $class; |
95
|
|
|
|
|
|
|
} |
96
|
1
|
|
|
1
|
|
9
|
sub name { shift->{name} } |
97
|
2
|
|
|
2
|
|
5
|
sub pkg_name { shift->{pkg_name} } |
98
|
2
|
|
|
2
|
|
4
|
sub sub_name { shift->{sub_name} } |
99
|
0
|
|
|
0
|
|
0
|
sub args { shift->{args} } |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub validate |
102
|
|
|
|
|
|
|
{ |
103
|
2
|
|
|
2
|
|
10
|
my ($self) = @_; |
104
|
2
|
|
|
|
|
6
|
my $pkg = $self->pkg_name; |
105
|
2
|
|
|
|
|
6
|
my $sub = $self->sub_name; |
106
|
2
|
|
|
|
|
7
|
$pkg =~ s,::,/,g; |
107
|
2
|
100
|
66
|
|
|
13
|
eval { require "$pkg.pm" } |
|
1
|
|
|
|
|
7
|
|
108
|
|
|
|
|
|
|
unless $pkg eq 'SQL/Statement/Functions' |
109
|
|
|
|
|
|
|
or $pkg eq 'main'; |
110
|
2
|
50
|
|
|
|
9
|
die $@ if $@; |
111
|
2
|
|
|
|
|
5
|
$pkg =~ s,/,::,g; |
112
|
2
|
100
|
|
|
|
31
|
die "Can't find subroutine $pkg" . "::$sub\n" unless $pkg->can($sub); |
113
|
1
|
|
|
|
|
6
|
return 1; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub run |
117
|
|
|
|
|
|
|
{ |
118
|
16
|
|
|
16
|
|
154
|
use SQL::Statement::Functions; |
|
16
|
|
|
|
|
36
|
|
|
16
|
|
|
|
|
1497
|
|
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
0
|
|
|
my ($self) = shift; |
121
|
0
|
|
|
|
|
|
my $sub = $self->sub_name; |
122
|
0
|
|
|
|
|
|
my $pkg = $self->pkg_name; |
123
|
0
|
|
|
|
|
|
return $pkg->$sub(@_); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=pod |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 NAME |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
SQL::Statement::Util |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SYNOPSIS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
SQL::Statement::Util::Column->new($col_name, $table_name, $term, $display_name) |
137
|
|
|
|
|
|
|
SQL::Statement::Util::AggregatedColumns($col_name, $table_name, $term, $display_name) |
138
|
|
|
|
|
|
|
SQL::Statement::Util::Function($name, $sub_name, $args) |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 DESCRIPTION |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
This package contains three utility classes to handle deliverable columns. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 INHERITANCE |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
SQL::Statement::Util::Column |
147
|
|
|
|
|
|
|
ISA SQL::Statement::Util |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
SQL::Statement::Util::AggregatedColumns |
150
|
|
|
|
|
|
|
ISA SQL::Statement::Util::Column |
151
|
|
|
|
|
|
|
ISA SQL::Statement::Util |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
SQL::Statement::Util::Function |
154
|
|
|
|
|
|
|
ISA SQL::Statement::Util |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=begin undocumented |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 METHODS |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 type |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Returns the type of the SQL::Statement::Util instance. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=end undocumented |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 AUTHOR & COPYRIGHT |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This module is |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
copyright (c) 2001,2005 by Jeff Zucker and |
171
|
|
|
|
|
|
|
copyright (c) 2007-2020 by Jens Rehsack. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
All rights reserved. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
The module may be freely distributed under the same terms as |
176
|
|
|
|
|
|
|
Perl itself using either the "GPL License" or the "Artistic |
177
|
|
|
|
|
|
|
License" as specified in the Perl README file. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Jeff can be reached at: jzuckerATcpan.org |
180
|
|
|
|
|
|
|
Jens can be reached at: rehsackATcpan.org or via dbi-devATperl.org |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |