line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::DataModel::Compatibility::V1; |
2
|
6
|
|
|
6
|
|
44
|
use strict; |
|
6
|
|
|
|
|
25
|
|
|
6
|
|
|
|
|
184
|
|
3
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
166
|
|
4
|
6
|
|
|
6
|
|
29
|
no strict 'refs'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
158
|
|
5
|
6
|
|
|
6
|
|
32
|
no warnings 'once'; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
224
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
2748
|
use DBIx::DataModel::Meta; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
204
|
|
8
|
6
|
|
|
6
|
|
3101
|
use DBIx::DataModel::Meta::Schema; |
|
6
|
|
|
|
|
20
|
|
|
6
|
|
|
|
|
219
|
|
9
|
6
|
|
|
6
|
|
40
|
use DBIx::DataModel::Meta::Source; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
122
|
|
10
|
6
|
|
|
6
|
|
29
|
use DBIx::DataModel::Meta::Utils; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
360
|
|
11
|
6
|
|
|
6
|
|
3319
|
use DBIx::DataModel::Schema; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
419
|
|
12
|
6
|
|
|
6
|
|
44
|
use DBIx::DataModel::Source; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
341
|
|
13
|
6
|
|
|
6
|
|
50
|
use DBIx::DataModel::Source::Table; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
152
|
|
14
|
6
|
|
|
6
|
|
3530
|
use DBIx::DataModel::Statement; |
|
6
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
201
|
|
15
|
6
|
|
|
6
|
|
3250
|
use DBIx::DataModel::Statement::JDBC; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
189
|
|
16
|
6
|
|
|
6
|
|
41
|
use SQL::Abstract::More; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
48
|
|
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
|
|
141
|
my $hashref = shift; |
23
|
81
|
|
|
|
|
262
|
foreach my $key (keys %$hashref) { |
24
|
129
|
|
|
|
|
226
|
my $new_key = $key; |
25
|
|
|
|
|
|
|
$new_key =~ s/([a-z])([A-Z])/$1_\L$2\E/g |
26
|
129
|
100
|
|
|
|
683
|
and $hashref->{$new_key} = delete $hashref->{$key}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# an exception for -postSQL |
30
|
81
|
50
|
|
|
|
310
|
$tmp = delete $hashref->{-post_sQL} and $hashref->{-post_SQL} = $tmp; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
34
|
|
|
|
|
|
|
package DBIx::DataModel; |
35
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
36
|
6
|
|
|
6
|
|
1053
|
use strict; |
|
6
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
186
|
|
37
|
6
|
|
|
6
|
|
33
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
195
|
|
38
|
6
|
|
|
6
|
|
36
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
2583
|
|
39
|
|
|
|
|
|
|
my $orig_Schema = \&Schema; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
*Schema = sub { |
42
|
9
|
|
|
9
|
|
25515
|
my ($class, $schema_class_name, %args) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# convert args received as camelCase |
45
|
9
|
|
|
|
|
35
|
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
|
|
|
|
|
15
|
my %singleton_args; |
49
|
9
|
|
|
|
|
22
|
foreach my $key (qw/dbh debug dbi_prepare_method |
50
|
|
|
|
|
|
|
sql_abstract sql_dialect/) { |
51
|
45
|
100
|
|
|
|
104
|
$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
|
|
|
|
30
|
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
|
|
|
|
|
39
|
my $schema_class = $class->$orig_Schema($schema_class_name, %args); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# also create a Schema singleton, if needed |
65
|
8
|
100
|
|
|
|
927
|
if (%singleton_args) { |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# recuperate existing SQLA instance, if any |
68
|
4
|
|
|
|
|
7
|
my %sqlam_args; |
69
|
4
|
50
|
|
|
|
25
|
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
|
|
|
|
11
|
if (my $dialect = delete $singleton_args{sql_dialect}) { |
85
|
4
|
100
|
|
|
|
12
|
if (ref $dialect) { |
86
|
2
|
|
|
|
|
6
|
DBIx::DataModel::Compatibility::V1::_rename_camelCase_keys($dialect); |
87
|
2
|
|
|
|
|
6
|
$sqlam_args{$_} = $dialect->{$_} foreach keys %$dialect; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else { |
90
|
2
|
|
|
|
|
16
|
$dialect =~ s/^MySQL/MySQL_old/; |
91
|
2
|
|
|
|
|
7
|
$sqlam_args{sql_dialect} = $dialect; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# create a new SQLAM instance |
97
|
4
|
|
|
|
|
47
|
$singleton_args{sql_abstract} = SQL::Abstract::More->new(%sqlam_args); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# create the singleton |
100
|
4
|
|
|
|
|
1206
|
my $singleton = $schema_class->singleton(%singleton_args); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
8
|
|
|
|
|
1789
|
return $schema_class; |
104
|
|
|
|
|
|
|
}; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
109
|
|
|
|
|
|
|
package DBIx::DataModel::Meta::Schema; |
110
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
111
|
6
|
|
|
6
|
|
49
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
155
|
|
112
|
6
|
|
|
6
|
|
35
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
213
|
|
113
|
6
|
|
|
6
|
|
36
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
1785
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $orig_Type = \&Type; |
116
|
|
|
|
|
|
|
*Type = *ColumnType = sub { |
117
|
2
|
|
|
2
|
|
10
|
my ($self, $type_name, %handlers) = @_; |
118
|
2
|
|
|
|
|
6
|
my $tmp; |
119
|
2
|
50
|
|
|
|
11
|
$tmp = delete $handlers{fromDB} and $handlers{from_DB} = $tmp; |
120
|
2
|
50
|
|
|
|
8
|
$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
|
|
25
|
my ($class, %options) = @_; |
128
|
|
|
|
|
|
|
|
129
|
9
|
|
|
|
|
40
|
$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
|
|
44
|
use strict; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
149
|
|
148
|
6
|
|
|
6
|
|
33
|
use warnings; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
204
|
|
149
|
6
|
|
|
6
|
|
44
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
181
|
|
150
|
6
|
|
|
6
|
|
32
|
use Carp; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
3499
|
|
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
|
20
|
my $self = shift; |
169
|
2
|
|
|
|
|
7
|
$self->metadm->Type(@_); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub Autoload { # installs or desinstalls an AUTOLOAD |
174
|
2
|
|
|
2
|
0
|
1627
|
my ($class, $toggle) = @_; |
175
|
|
|
|
|
|
|
|
176
|
2
|
|
|
|
|
14
|
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
|
5551
|
my ($class, %handlers) = @_; |
197
|
1
|
|
|
|
|
6
|
$class->metadm->{auto_insert_columns} = \%handlers; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub AutoUpdateColumns { |
201
|
1
|
|
|
1
|
0
|
4905
|
my ($class, %handlers) = @_; |
202
|
1
|
|
|
|
|
7
|
$class->metadm->{auto_update_columns} = \%handlers; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub NoUpdateColumns { |
206
|
2
|
|
|
2
|
0
|
18
|
my ($class, @columns) = @_; |
207
|
2
|
|
|
|
|
6
|
$class->metadm->{no_update_columns} = {map {$_ => 1} @columns}; |
|
4
|
|
|
|
|
17
|
|
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
|
13
|
my $class = shift; |
229
|
1
|
|
|
|
|
8
|
return $class->localize_state; |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
234
|
|
|
|
|
|
|
package DBIx::DataModel::Source; |
235
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
236
|
6
|
|
|
6
|
|
53
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
153
|
|
237
|
6
|
|
|
6
|
|
50
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
187
|
|
238
|
6
|
|
|
6
|
|
31
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
238
|
|
239
|
6
|
|
|
6
|
|
39
|
use Carp; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
2621
|
|
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
|
|
13
|
my $self = shift; |
268
|
2
|
|
33
|
|
|
6
|
my $class = ref($self) || $self; |
269
|
2
|
|
|
|
|
6
|
my $attribute = our $AUTOLOAD; |
270
|
2
|
|
|
|
|
13
|
$attribute =~ s/^.*:://; |
271
|
2
|
50
|
|
|
|
7
|
return if $attribute eq 'DESTROY'; # won't overload that one! |
272
|
|
|
|
|
|
|
|
273
|
2
|
50
|
33
|
|
|
23
|
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
|
9
|
my ($class, $toggle) = @_; |
280
|
|
|
|
|
|
|
|
281
|
4
|
50
|
|
|
|
12
|
not ref($class) or croak "Autoload is a class method"; |
282
|
4
|
50
|
|
|
|
12
|
defined($toggle) or croak "Autoload : missing toggle value"; |
283
|
|
|
|
|
|
|
|
284
|
6
|
|
|
6
|
|
45
|
no strict 'refs'; |
|
6
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
728
|
|
285
|
4
|
100
|
|
|
|
11
|
if ($toggle) { |
286
|
2
|
|
|
|
|
4
|
*{"${class}::AUTOLOAD"} = \&_autoloader; |
|
2
|
|
|
|
|
29
|
|
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
else { |
289
|
2
|
|
|
|
|
3
|
delete ${"${class}::"}{AUTOLOAD}; |
|
2
|
|
|
|
|
19
|
|
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
296
|
|
|
|
|
|
|
package DBIx::DataModel::Source::Table; |
297
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
298
|
6
|
|
|
6
|
|
43
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
162
|
|
299
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
179
|
|
300
|
6
|
|
|
6
|
|
43
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
3395
|
|
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
|
33
|
my ($class, $typeName, @args) = @_; |
309
|
4
|
|
|
|
|
13
|
$class->metadm->define_column_type($typeName, @args); |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub ColumnHandlers { |
313
|
2
|
|
|
2
|
1
|
36
|
my ($class, $columnName, %handlers) = @_; |
314
|
2
|
|
|
|
|
24
|
$class->metadm->define_column_handlers($columnName, %handlers); |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
sub AutoExpand { |
318
|
2
|
|
|
2
|
1
|
13
|
my ($class, @roles) = @_; |
319
|
2
|
|
|
|
|
6
|
$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
|
|
|
|
|
13
|
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
|
8
|
my $class = shift; |
345
|
1
|
|
|
|
|
9
|
$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
|
13
|
my ($class, @columns) = @_; |
360
|
2
|
|
|
|
|
5
|
$class->metadm->{no_update_columns} = {map {$_ => 1} @columns}; |
|
2
|
|
|
|
|
10
|
|
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
sub blessFromDB { |
364
|
9
|
|
|
9
|
1
|
7851
|
my $class = shift; |
365
|
9
|
|
|
|
|
56
|
$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
|
|
47
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
170
|
|
377
|
6
|
|
|
6
|
|
45
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
209
|
|
378
|
6
|
|
|
6
|
|
42
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
221
|
|
379
|
6
|
|
|
6
|
|
39
|
use Carp; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
409
|
|
380
|
6
|
|
|
6
|
|
58
|
use Scalar::Util qw/reftype/; |
|
6
|
|
|
|
|
25
|
|
|
6
|
|
|
|
|
871
|
|
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
my $orig_refine = \&refine; |
383
|
|
|
|
|
|
|
*refine = sub { |
384
|
70
|
|
|
70
|
|
152
|
my $self = shift; |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
# parse named or positional arguments |
387
|
70
|
|
|
|
|
123
|
my %args; |
388
|
70
|
100
|
66
|
|
|
532
|
if ($_[0] and not ref($_[0]) and $_[0] =~ /^-/) { # called with named args |
|
|
|
100
|
|
|
|
|
389
|
57
|
|
|
|
|
193
|
%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
|
|
42
|
no warnings 'uninitialized'; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
2123
|
|
394
|
13
|
100
|
66
|
|
|
105
|
$args{-columns} = shift unless !@_ or reftype $_[0] eq 'HASH' ; |
395
|
13
|
100
|
66
|
|
|
82
|
$args{-where} = shift unless !@_ or reftype $_[0] eq 'ARRAY'; |
396
|
13
|
100
|
66
|
|
|
71
|
$args{-orderBy} = shift unless !@_ or reftype $_[0] eq 'HASH' ; |
397
|
13
|
50
|
|
|
|
41
|
croak "too many args for select()" if @_; |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
# camelCase keys |
401
|
70
|
|
|
|
|
225
|
DBIx::DataModel::Compatibility::V1::_rename_camelCase_keys(\%args); |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
# -distinct => \@columns is now -columns => [-distinct => @columns] |
404
|
70
|
100
|
|
|
|
186
|
if (my $distinct = delete $args{-distinct}) { |
405
|
2
|
100
|
|
|
|
9
|
ref $distinct or $distinct = [$distinct]; |
406
|
2
|
|
|
|
|
8
|
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
|
|
|
|
196
|
if $args{-result_as}; |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
# delegate to the real refine() method |
415
|
70
|
|
|
|
|
259
|
$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
|
|
48
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
164
|
|
430
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
228
|
|
431
|
6
|
|
|
6
|
|
49
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
191
|
|
432
|
6
|
|
|
6
|
|
31
|
use Carp; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
1105
|
|
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__ |