line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::DataModel::Compatibility::V1; |
2
|
6
|
|
|
6
|
|
46
|
use strict; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
193
|
|
3
|
6
|
|
|
6
|
|
35
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
179
|
|
4
|
6
|
|
|
6
|
|
29
|
no strict 'refs'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
153
|
|
5
|
6
|
|
|
6
|
|
34
|
no warnings 'once'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
264
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
2910
|
use DBIx::DataModel::Meta; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
174
|
|
8
|
6
|
|
|
6
|
|
3237
|
use DBIx::DataModel::Meta::Schema; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
226
|
|
9
|
6
|
|
|
6
|
|
43
|
use DBIx::DataModel::Meta::Source; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
128
|
|
10
|
6
|
|
|
6
|
|
31
|
use DBIx::DataModel::Meta::Utils; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
382
|
|
11
|
6
|
|
|
6
|
|
3668
|
use DBIx::DataModel::Schema; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
464
|
|
12
|
6
|
|
|
6
|
|
59
|
use DBIx::DataModel::Source; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
372
|
|
13
|
6
|
|
|
6
|
|
52
|
use DBIx::DataModel::Source::Table; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
156
|
|
14
|
6
|
|
|
6
|
|
3845
|
use DBIx::DataModel::Statement; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
225
|
|
15
|
6
|
|
|
6
|
|
3544
|
use DBIx::DataModel::Statement::JDBC; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
199
|
|
16
|
6
|
|
|
6
|
|
40
|
use SQL::Abstract::More; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
81
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $tmp; # used for various renaming loops |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# utility fonction for replacing 'camelCase' keys in hashs by 'camel_case' |
21
|
|
|
|
|
|
|
sub _rename_camelCase_keys { |
22
|
81
|
|
|
81
|
|
164
|
my $hashref = shift; |
23
|
81
|
|
|
|
|
240
|
foreach my $key (keys %$hashref) { |
24
|
129
|
|
|
|
|
224
|
my $new_key = $key; |
25
|
|
|
|
|
|
|
$new_key =~ s/([a-z])([A-Z])/$1_\L$2\E/g |
26
|
129
|
100
|
|
|
|
822
|
and $hashref->{$new_key} = delete $hashref->{$key}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# an exception for -postSQL |
30
|
81
|
50
|
|
|
|
309
|
$tmp = delete $hashref->{-post_sQL} and $hashref->{-post_SQL} = $tmp; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
34
|
|
|
|
|
|
|
package DBIx::DataModel; |
35
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
36
|
6
|
|
|
6
|
|
1158
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
137
|
|
37
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
6
|
|
|
|
|
28
|
|
|
6
|
|
|
|
|
226
|
|
38
|
6
|
|
|
6
|
|
37
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
2762
|
|
39
|
|
|
|
|
|
|
my $orig_Schema = \&Schema; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
*Schema = sub { |
42
|
9
|
|
|
9
|
|
27224
|
my ($class, $schema_class_name, %args) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# convert args received as camelCase |
45
|
9
|
|
|
|
|
38
|
DBIx::DataModel::Compatibility::V1::_rename_camelCase_keys(\%args); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# extract args that should go to DBIDM::Schema and not DBIDM::Meta::Schema |
48
|
9
|
|
|
|
|
18
|
my %singleton_args; |
49
|
9
|
|
|
|
|
27
|
foreach my $key (qw/dbh debug dbi_prepare_method |
50
|
|
|
|
|
|
|
sql_abstract sql_dialect/) { |
51
|
45
|
100
|
|
|
|
138
|
$tmp = delete $args{$key} and $singleton_args{$key} = $tmp; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# view_parent is now join_parent (not 100% correct, but the best we can do) |
55
|
9
|
100
|
|
|
|
29
|
if (my $vp = delete $args{view_parent}) { |
56
|
1
|
|
50
|
|
|
6
|
$args{join_parent} ||= []; |
57
|
1
|
50
|
|
|
|
4
|
$args{join_parent} = [$args{join_parent}] unless ref $args{join_parent}; |
58
|
1
|
|
|
|
|
2
|
push @{$args{join_parent}}, @$vp; |
|
1
|
|
|
|
|
3
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# create the Meta::Schema |
62
|
9
|
|
|
|
|
60
|
my $schema_class = $class->$orig_Schema($schema_class_name, %args); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# also create a Schema singleton, if needed |
65
|
8
|
100
|
|
|
|
28
|
if (%singleton_args) { |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# recuperate existing SQLA instance, if any |
68
|
4
|
|
|
|
|
6
|
my %sqlam_args; |
69
|
4
|
50
|
|
|
|
16
|
if (my $sqla = delete $singleton_args{sql_abstract}) { |
70
|
|
|
|
|
|
|
# create a fake SQLA object in order to know how many builtin ops it has |
71
|
0
|
|
|
|
|
0
|
my $fake_sqla = SQL::Abstract->new; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# surgery: remove builtin ops from our $sqla object |
74
|
0
|
|
|
|
|
0
|
for my $op_name (qw/special_ops unary_ops/) { |
75
|
0
|
|
|
|
|
0
|
my $n_builtin_ops = @{$fake_sqla->{$op_name}}; |
|
0
|
|
|
|
|
0
|
|
76
|
0
|
|
|
|
|
0
|
splice @{$sqla->{$op_name}}, -$n_builtin_ops; |
|
0
|
|
|
|
|
0
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# now inject the remaining stuff in $sqla as argument for a SQLAM object |
80
|
0
|
0
|
|
|
|
0
|
%sqlam_args = %$sqla if $sqla; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# sql_dialect, previously passed to Schema, is now passed to SQLAM |
84
|
4
|
50
|
|
|
|
16
|
if (my $dialect = delete $singleton_args{sql_dialect}) { |
85
|
4
|
100
|
|
|
|
11
|
if (ref $dialect) { |
86
|
2
|
|
|
|
|
6
|
DBIx::DataModel::Compatibility::V1::_rename_camelCase_keys($dialect); |
87
|
2
|
|
|
|
|
13
|
$sqlam_args{$_} = $dialect->{$_} foreach keys %$dialect; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else { |
90
|
2
|
|
|
|
|
10
|
$dialect =~ s/^MySQL/MySQL_old/; |
91
|
2
|
|
|
|
|
5
|
$sqlam_args{sql_dialect} = $dialect; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# create a new SQLAM instance |
97
|
4
|
|
|
|
|
33
|
$singleton_args{sql_abstract} = SQL::Abstract::More->new(%sqlam_args); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# create the singleton |
100
|
4
|
|
|
|
|
1318
|
my $singleton = $schema_class->singleton(%singleton_args); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
8
|
|
|
|
|
1995
|
return $schema_class; |
104
|
|
|
|
|
|
|
}; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
109
|
|
|
|
|
|
|
package DBIx::DataModel::Meta::Schema; |
110
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
111
|
6
|
|
|
6
|
|
61
|
use strict; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
261
|
|
112
|
6
|
|
|
6
|
|
41
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
181
|
|
113
|
6
|
|
|
6
|
|
57
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
1827
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $orig_Type = \&Type; |
116
|
|
|
|
|
|
|
*Type = *ColumnType = sub { |
117
|
2
|
|
|
2
|
|
13
|
my ($self, $type_name, %handlers) = @_; |
118
|
2
|
|
|
|
|
44
|
my $tmp; |
119
|
2
|
50
|
|
|
|
13
|
$tmp = delete $handlers{fromDB} and $handlers{from_DB} = $tmp; |
120
|
2
|
50
|
|
|
|
9
|
$tmp = delete $handlers{toDB} and $handlers{to_DB} = $tmp; |
121
|
2
|
|
|
|
|
13
|
$self->$orig_Type($type_name, %handlers); |
122
|
|
|
|
|
|
|
}; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $orig_new = \&new; |
126
|
|
|
|
|
|
|
*new = sub { |
127
|
9
|
|
|
9
|
|
38
|
my ($class, %options) = @_; |
128
|
|
|
|
|
|
|
|
129
|
9
|
|
|
|
|
51
|
$class->$orig_new(sql_no_inner_after_left_join => 1, %options); |
130
|
|
|
|
|
|
|
}; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub tables { # return classname instead of metadm instance |
134
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
135
|
0
|
|
|
|
|
0
|
return map {$_->class} values %{$self->{table}}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub views { |
139
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
140
|
0
|
|
|
|
|
0
|
return map {$_->class} values %{$self->{table}}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
145
|
|
|
|
|
|
|
package DBIx::DataModel::Schema; |
146
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
147
|
6
|
|
|
6
|
|
76
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
196
|
|
148
|
6
|
|
|
6
|
|
42
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
166
|
|
149
|
6
|
|
|
6
|
|
30
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
253
|
|
150
|
6
|
|
|
6
|
|
39
|
use Carp; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
4791
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
*_createPackage = \&DBIx::DataModel::Meta::Utils::define_class; |
154
|
|
|
|
|
|
|
*doTransaction = \&do_transaction; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub _defineMethod { |
157
|
0
|
|
|
0
|
|
0
|
my ($class, $target, $method_name, $body, $is_silent) = @_; |
158
|
0
|
|
|
|
|
0
|
my %args = ( |
159
|
|
|
|
|
|
|
class => $target, |
160
|
|
|
|
|
|
|
name => $method_name, |
161
|
|
|
|
|
|
|
body => $body, |
162
|
|
|
|
|
|
|
); |
163
|
0
|
0
|
|
|
|
0
|
$args{check_override} = 0 if $is_silent; |
164
|
0
|
|
|
|
|
0
|
DBIx::DataModel::Meta::Utils->define_method(%args); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub ColumnType { |
168
|
2
|
|
|
2
|
0
|
19
|
my $self = shift; |
169
|
2
|
|
|
|
|
9
|
$self->metadm->Type(@_); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub Autoload { # installs or desinstalls an AUTOLOAD |
174
|
2
|
|
|
2
|
0
|
2086
|
my ($class, $toggle) = @_; |
175
|
|
|
|
|
|
|
|
176
|
2
|
|
|
|
|
12
|
DBIx::DataModel::Source::Table->Autoload($toggle); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub autoInsertColumns { |
180
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
181
|
0
|
|
|
|
|
0
|
return $class->metadm->auto_insert_columns; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub autoUpdateColumns { |
185
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
186
|
0
|
|
|
|
|
0
|
return $class->metadm->auto_update_columns; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub noUpdateColumns { |
190
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
191
|
0
|
|
|
|
|
0
|
my %no_update_column = $class->metadm->no_update_column; |
192
|
0
|
|
|
|
|
0
|
return keys %no_update_column; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub AutoInsertColumns { |
196
|
1
|
|
|
1
|
0
|
6408
|
my ($class, %handlers) = @_; |
197
|
1
|
|
|
|
|
6
|
$class->metadm->{auto_insert_columns} = \%handlers; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub AutoUpdateColumns { |
201
|
1
|
|
|
1
|
0
|
5591
|
my ($class, %handlers) = @_; |
202
|
1
|
|
|
|
|
6
|
$class->metadm->{auto_update_columns} = \%handlers; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub NoUpdateColumns { |
206
|
2
|
|
|
2
|
0
|
34
|
my ($class, @columns) = @_; |
207
|
2
|
|
|
|
|
7
|
$class->metadm->{no_update_columns} = {map {$_ => 1} @columns}; |
|
4
|
|
|
|
|
19
|
|
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub tables { |
212
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
213
|
0
|
|
|
|
|
0
|
$class->metadm->tables; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub selectImplicitlyFor { |
218
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
219
|
0
|
|
|
|
|
0
|
$self->select_implicitly_for(@_); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub classData { |
223
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
224
|
0
|
|
|
|
|
0
|
return $class->singleton; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub localizeState { |
228
|
1
|
|
|
1
|
0
|
15
|
my $class = shift; |
229
|
1
|
|
|
|
|
8
|
return $class->localize_state; |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
234
|
|
|
|
|
|
|
package DBIx::DataModel::Source; |
235
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
236
|
6
|
|
|
6
|
|
52
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
178
|
|
237
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
272
|
|
238
|
6
|
|
|
6
|
|
40
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
210
|
|
239
|
6
|
|
|
6
|
|
33
|
use Carp; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
2632
|
|
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
*primKey = \&primary_key; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub MethodFromJoin { |
244
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
245
|
0
|
|
|
|
|
0
|
$self->metadm->define_navigation_method(@_); |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub createStatement { |
249
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
250
|
|
|
|
|
|
|
|
251
|
0
|
|
|
|
|
0
|
carp "->createStatement() is obsolete, use " |
252
|
|
|
|
|
|
|
. "->select(.., -resultAs => 'statement')"; |
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
0
|
return $class->select(@_, -resultAs => 'statement'); |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub selectImplicitlyFor { |
258
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
259
|
|
|
|
|
|
|
|
260
|
0
|
|
|
|
|
0
|
carp "HACK: obsolete method \$source->selectImplicitlyFor() is delegated " |
261
|
|
|
|
|
|
|
. "to \$schema->select_implicitly_for(); the semantics is not exactly " |
262
|
|
|
|
|
|
|
. "identical"; |
263
|
0
|
|
|
|
|
0
|
$self->metadm->schema->class->select_implicitly_for(@_); |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub _autoloader { |
267
|
2
|
|
|
2
|
|
12
|
my $self = shift; |
268
|
2
|
|
33
|
|
|
7
|
my $class = ref($self) || $self; |
269
|
2
|
|
|
|
|
4
|
my $attribute = our $AUTOLOAD; |
270
|
2
|
|
|
|
|
13
|
$attribute =~ s/^.*:://; |
271
|
2
|
50
|
|
|
|
8
|
return if $attribute eq 'DESTROY'; # won't overload that one! |
272
|
|
|
|
|
|
|
|
273
|
2
|
50
|
33
|
|
|
25
|
return $self->{$attribute} if ref($self) and exists $self->{$attribute}; |
274
|
|
|
|
|
|
|
|
275
|
0
|
|
|
|
|
0
|
croak "no $attribute method in $class"; # otherwise |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
sub Autoload { # installs or desinstalls an AUTOLOAD in $package |
279
|
4
|
|
|
4
|
0
|
10
|
my ($class, $toggle) = @_; |
280
|
|
|
|
|
|
|
|
281
|
4
|
50
|
|
|
|
13
|
not ref($class) or croak "Autoload is a class method"; |
282
|
4
|
50
|
|
|
|
10
|
defined($toggle) or croak "Autoload : missing toggle value"; |
283
|
|
|
|
|
|
|
|
284
|
6
|
|
|
6
|
|
61
|
no strict 'refs'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
749
|
|
285
|
4
|
100
|
|
|
|
12
|
if ($toggle) { |
286
|
2
|
|
|
|
|
4
|
*{"${class}::AUTOLOAD"} = \&_autoloader; |
|
2
|
|
|
|
|
31
|
|
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
else { |
289
|
2
|
|
|
|
|
4
|
delete ${"${class}::"}{AUTOLOAD}; |
|
2
|
|
|
|
|
18
|
|
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
296
|
|
|
|
|
|
|
package DBIx::DataModel::Source::Table; |
297
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
298
|
6
|
|
|
6
|
|
41
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
184
|
|
299
|
6
|
|
|
6
|
|
56
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
195
|
|
300
|
6
|
|
|
6
|
|
36
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
3569
|
|
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub DefaultColumns { |
303
|
0
|
|
|
0
|
1
|
0
|
my ($class, $columns) = @_; |
304
|
0
|
|
|
|
|
0
|
$class->metadm->default_columns($columns); |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
sub ColumnType { |
308
|
4
|
|
|
4
|
1
|
48
|
my ($class, $typeName, @args) = @_; |
309
|
4
|
|
|
|
|
12
|
$class->metadm->define_column_type($typeName, @args); |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub ColumnHandlers { |
313
|
2
|
|
|
2
|
1
|
17
|
my ($class, $columnName, %handlers) = @_; |
314
|
2
|
|
|
|
|
8
|
$class->metadm->define_column_handlers($columnName, %handlers); |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
sub AutoExpand { |
318
|
2
|
|
|
2
|
1
|
19
|
my ($class, @roles) = @_; |
319
|
2
|
|
|
|
|
9
|
$class->metadm->define_auto_expand(@roles); |
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
sub autoInsertColumns { |
323
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
324
|
0
|
|
|
|
|
0
|
$self->metadm->auto_insert_column; |
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
sub autoUpdateColumns { |
328
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
329
|
0
|
|
|
|
|
0
|
$self->metadm->auto_update_column; |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
sub noUpdateColumns { |
333
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
334
|
1
|
|
|
|
|
3
|
my %no_update_columns = $self->metadm->no_update_column; |
335
|
1
|
|
|
|
|
14
|
return keys %no_update_columns; |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub componentRoles { |
339
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
340
|
0
|
|
|
|
|
0
|
$self->metadm->components; |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
sub applyColumnHandler { |
344
|
1
|
|
|
1
|
1
|
9
|
my $class = shift; |
345
|
1
|
|
|
|
|
7
|
$class->apply_column_handler(@_); |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
sub AutoInsertColumns { |
349
|
0
|
|
|
0
|
0
|
0
|
my ($class, %handlers) = @_; |
350
|
0
|
|
|
|
|
0
|
$class->metadm->{auto_insert_columns} = \%handlers; |
351
|
|
|
|
|
|
|
} |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
sub AutoUpdateColumns { |
354
|
0
|
|
|
0
|
0
|
0
|
my ($class, %handlers) = @_; |
355
|
0
|
|
|
|
|
0
|
$class->metadm->{auto_update_columns} = \%handlers; |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
sub NoUpdateColumns { |
359
|
2
|
|
|
2
|
0
|
12
|
my ($class, @columns) = @_; |
360
|
2
|
|
|
|
|
5
|
$class->metadm->{no_update_columns} = {map {$_ => 1} @columns}; |
|
2
|
|
|
|
|
9
|
|
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
sub blessFromDB { |
364
|
9
|
|
|
9
|
1
|
8428
|
my $class = shift; |
365
|
9
|
|
|
|
|
53
|
$class->bless_from_DB(@_); |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
sub db_table { |
369
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
370
|
0
|
|
|
|
|
0
|
return $class->metadm->db_from; |
371
|
|
|
|
|
|
|
} |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
374
|
|
|
|
|
|
|
package DBIx::DataModel::Statement; |
375
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
376
|
6
|
|
|
6
|
|
45
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
155
|
|
377
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
212
|
|
378
|
6
|
|
|
6
|
|
38
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
23
|
|
|
6
|
|
|
|
|
190
|
|
379
|
6
|
|
|
6
|
|
42
|
use Carp; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
478
|
|
380
|
6
|
|
|
6
|
|
53
|
use Scalar::Util qw/reftype/; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
894
|
|
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
my $orig_refine = \&refine; |
383
|
|
|
|
|
|
|
*refine = sub { |
384
|
70
|
|
|
70
|
|
151
|
my $self = shift; |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
# parse named or positional arguments |
387
|
70
|
|
|
|
|
129
|
my %args; |
388
|
70
|
100
|
66
|
|
|
633
|
if ($_[0] and not ref($_[0]) and $_[0] =~ /^-/) { # called with named args |
|
|
|
100
|
|
|
|
|
389
|
57
|
|
|
|
|
242
|
%args = @_; |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
else { # we were called with unnamed args (all optional!), so we try |
392
|
|
|
|
|
|
|
# to guess which is which from their datatypes. |
393
|
6
|
|
|
6
|
|
45
|
no warnings 'uninitialized'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
2221
|
|
394
|
13
|
100
|
66
|
|
|
133
|
$args{-columns} = shift unless !@_ or reftype $_[0] eq 'HASH' ; |
395
|
13
|
100
|
66
|
|
|
90
|
$args{-where} = shift unless !@_ or reftype $_[0] eq 'ARRAY'; |
396
|
13
|
100
|
66
|
|
|
62
|
$args{-orderBy} = shift unless !@_ or reftype $_[0] eq 'HASH' ; |
397
|
13
|
50
|
|
|
|
35
|
croak "too many args for select()" if @_; |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
# camelCase keys |
401
|
70
|
|
|
|
|
236
|
DBIx::DataModel::Compatibility::V1::_rename_camelCase_keys(\%args); |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
# -distinct => \@columns is now -columns => [-distinct => @columns] |
404
|
70
|
100
|
|
|
|
206
|
if (my $distinct = delete $args{-distinct}) { |
405
|
2
|
100
|
|
|
|
9
|
ref $distinct or $distinct = [$distinct]; |
406
|
2
|
|
|
|
|
7
|
unshift @$distinct, '-distinct'; |
407
|
2
|
|
|
|
|
5
|
$args{-columns} = $distinct; |
408
|
|
|
|
|
|
|
} |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
# various old ways to require -result_as => 'statement' |
411
|
|
|
|
|
|
|
$args{-result_as} =~ s/^(cursor|iter(ator)?)/statement/i |
412
|
70
|
100
|
|
|
|
1900
|
if $args{-result_as}; |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
# delegate to the real refine() method |
415
|
70
|
|
|
|
|
273
|
$self->$orig_refine(%args); |
416
|
|
|
|
|
|
|
}; |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
*{rowCount} = \&row_count; |
419
|
|
|
|
|
|
|
*{pageCount} = \&page_count; |
420
|
|
|
|
|
|
|
*{gotoPage} = \&goto_page; |
421
|
|
|
|
|
|
|
*{shiftPages} = \&shift_pages; |
422
|
|
|
|
|
|
|
*{nextPage} = \&next_page; |
423
|
|
|
|
|
|
|
*{pageBoundaries} = \&page_boundaries; |
424
|
|
|
|
|
|
|
*{pageRows} = \&page_rows; |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
427
|
|
|
|
|
|
|
package DBIx::DataModel::Statement::JDBC; |
428
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
429
|
6
|
|
|
6
|
|
49
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
193
|
|
430
|
6
|
|
|
6
|
|
39
|
use warnings; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
194
|
|
431
|
6
|
|
|
6
|
|
32
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
232
|
|
432
|
6
|
|
|
6
|
|
37
|
use Carp; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
1122
|
|
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
*{rowCount} = \&row_count; |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
# simulate previous classes, now moved into the Source:: namespace, so that |
438
|
|
|
|
|
|
|
# they can be inherited from |
439
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
440
|
|
|
|
|
|
|
package DBIx::DataModel::Table; |
441
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
442
|
|
|
|
|
|
|
$INC{"DBIx/DataModel/Table.pm"} = 1; |
443
|
|
|
|
|
|
|
our @ISA = qw/DBIx::DataModel::Source::Table/; |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
447
|
|
|
|
|
|
|
package DBIx::DataModel::View; |
448
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
449
|
|
|
|
|
|
|
$INC{"DBIx/DataModel/View.pm"} = 1; |
450
|
|
|
|
|
|
|
our @ISA = qw/DBIx::DataModel::Source::Table/; |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
1; |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
__END__ |