line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Helper::Model::DBIC::Schema; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
78605
|
use namespace::autoclean; |
|
2
|
|
|
|
|
19243
|
|
|
2
|
|
|
|
|
15
|
|
4
|
2
|
|
|
2
|
|
711
|
use Moose; |
|
2
|
|
|
|
|
486791
|
|
|
2
|
|
|
|
|
16
|
|
5
|
2
|
|
|
2
|
|
15815
|
no warnings 'uninitialized'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
204
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.66'; |
8
|
|
|
|
|
|
|
$VERSION =~ tr/_//d; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
16
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
193
|
|
11
|
2
|
|
|
2
|
|
1350
|
use Tie::IxHash (); |
|
2
|
|
|
|
|
8169
|
|
|
2
|
|
|
|
|
55
|
|
12
|
2
|
|
|
2
|
|
640
|
use Data::Dumper (); |
|
2
|
|
|
|
|
7084
|
|
|
2
|
|
|
|
|
58
|
|
13
|
2
|
|
|
2
|
|
14
|
use List::Util 'first'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
159
|
|
14
|
2
|
|
|
2
|
|
457
|
use MooseX::Types::Moose qw/Str HashRef Bool ArrayRef/; |
|
2
|
|
|
|
|
61981
|
|
|
2
|
|
|
|
|
26
|
|
15
|
2
|
|
|
2
|
|
12338
|
use Catalyst::Model::DBIC::Schema::Types 'CreateOption'; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
29
|
|
16
|
2
|
|
|
2
|
|
4745
|
use List::MoreUtils 'firstidx'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
21
|
|
17
|
2
|
|
|
2
|
|
1506
|
use Scalar::Util 'looks_like_number'; |
|
2
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
138
|
|
18
|
2
|
|
|
2
|
|
25
|
use File::Find 'finddepth'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
148
|
|
19
|
2
|
|
|
2
|
|
23
|
use Try::Tiny; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
121
|
|
20
|
2
|
|
|
2
|
|
15
|
use Cwd 'getcwd'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
99
|
|
21
|
2
|
|
|
2
|
|
15
|
use Module::Runtime 'use_module'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
18
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Catalyst::Helper::Model::DBIC::Schema - Helper for DBIC Schema Models |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
script/create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass \ |
30
|
|
|
|
|
|
|
[ create=dynamic | create=static ] [ traits=trait1,trait2... ] \ |
31
|
|
|
|
|
|
|
[ Schema::Loader opts ] [ dsn user pass ] \ |
32
|
|
|
|
|
|
|
[ other connect_info args ] |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Helper for the DBIC Schema Models. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 Arguments: |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
C<CatalystModelName> is the short name for the Catalyst Model class |
41
|
|
|
|
|
|
|
being generated (i.e. callable with C<$c-E<gt>model('CatalystModelName')>). |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
C<MyApp::SchemaClass> is the fully qualified classname of your Schema, |
44
|
|
|
|
|
|
|
which might or might not yet exist. Note that you should have a good |
45
|
|
|
|
|
|
|
reason to create this under a new global namespace, otherwise use an |
46
|
|
|
|
|
|
|
existing top level namespace for your schema class. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
C<create=dynamic> instructs this Helper to generate the named Schema |
49
|
|
|
|
|
|
|
class for you, basing it on L<DBIx::Class::Schema::Loader> (which |
50
|
|
|
|
|
|
|
means the table information will always be dynamically loaded at |
51
|
|
|
|
|
|
|
runtime from the database). |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
C<create=static> instructs this Helper to generate the named Schema |
54
|
|
|
|
|
|
|
class for you, using L<DBIx::Class::Schema::Loader> in "one shot" |
55
|
|
|
|
|
|
|
mode to create a standard, manually-defined L<DBIx::Class::Schema> |
56
|
|
|
|
|
|
|
setup, based on what the Loader sees in your database at this moment. |
57
|
|
|
|
|
|
|
A Schema/Model pair generated this way will not require |
58
|
|
|
|
|
|
|
L<DBIx::Class::Schema::Loader> at runtime, and will not automatically |
59
|
|
|
|
|
|
|
adapt itself to changes in your database structure. You can edit |
60
|
|
|
|
|
|
|
the generated classes by hand to refine them. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
C<traits> is the list of traits to apply to the model, see |
63
|
|
|
|
|
|
|
L<Catalyst::Model::DBIC::Schema> for details. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
C<Schema::Loader opts> are documented in L<DBIx::Class::Schema::Loader::Base> |
66
|
|
|
|
|
|
|
and some examples are given in L</TYPICAL EXAMPLES> below. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
C<connect_info> arguments are the same as what L<DBIx::Class::Schema/connect> |
69
|
|
|
|
|
|
|
expects, and are storage_type-specific. They are documented in |
70
|
|
|
|
|
|
|
L<DBIx::Class::Storage::DBI/connect_info>. For DBI-based storage, these |
71
|
|
|
|
|
|
|
arguments are the dsn, username, password, and connect options, respectively. |
72
|
|
|
|
|
|
|
These are optional for existing Schemas, but required if you use either of the |
73
|
|
|
|
|
|
|
C<create=> options. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
username and password can be omitted for C<SQLite> dsns. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Use of either of the C<create=> options requires L<DBIx::Class::Schema::Loader>. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 TYPICAL EXAMPLES |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Use DBIx::Class::Schema::Loader to create a static DBIx::Class::Schema, |
82
|
|
|
|
|
|
|
and a Model which references it: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
script/myapp_create.pl model CatalystModelName DBIC::Schema \ |
85
|
|
|
|
|
|
|
MyApp::SchemaClass create=static dbi:mysql:foodb myuname mypass |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Same, with extra connect_info args |
88
|
|
|
|
|
|
|
user and pass can be omitted for sqlite, since they are always empty |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
script/myapp_create.pl model CatalystModelName DBIC::Schema \ |
91
|
|
|
|
|
|
|
MyApp::SchemaClass create=static dbi:SQLite:foo.db \ |
92
|
|
|
|
|
|
|
AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \ |
93
|
|
|
|
|
|
|
on_connect_do='["select 1", "select 2"]' quote_names=1 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
B<ON WINDOWS COMMAND LINES QUOTING RULES ARE DIFFERENT> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
In C<cmd.exe> the above example would be: |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
script/myapp_create.pl model CatalystModelName DBIC::Schema \ |
100
|
|
|
|
|
|
|
MyApp::SchemaClass create=static dbi:SQLite:foo.db \ |
101
|
|
|
|
|
|
|
AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \ |
102
|
|
|
|
|
|
|
on_connect_do="[\"select 1\", \"select 2\"]" quote_names=1 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Same, but with extra Schema::Loader args (separate multiple values by commas): |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
script/myapp_create.pl model CatalystModelName DBIC::Schema \ |
107
|
|
|
|
|
|
|
MyApp::SchemaClass create=static db_schema=foodb components=Foo,Bar \ |
108
|
|
|
|
|
|
|
exclude='^(wibble|wobble)$' moniker_map='{ foo => "FOO" }' \ |
109
|
|
|
|
|
|
|
dbi:Pg:dbname=foodb myuname mypass |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Coderefs are also supported: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
script/myapp_create.pl model CatalystModelName DBIC::Schema \ |
114
|
|
|
|
|
|
|
MyApp::SchemaClass create=static \ |
115
|
|
|
|
|
|
|
inflect_singular='sub { $_[0] =~ /\A(.+?)(_id)?\z/; $1 }' \ |
116
|
|
|
|
|
|
|
moniker_map='sub { join(q{}, map ucfirst, split(/[\W_]+/, lc $_[0])); }' \ |
117
|
|
|
|
|
|
|
dbi:mysql:foodb myuname mypass |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
See L<DBIx::Class::Schema::Loader::Base> for a list of options |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Create a dynamic DBIx::Class::Schema::Loader-based Schema, |
122
|
|
|
|
|
|
|
and a Model which references it (B<DEPRECATED>): |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
script/myapp_create.pl model CatalystModelName DBIC::Schema \ |
125
|
|
|
|
|
|
|
MyApp::SchemaClass create=dynamic dbi:mysql:foodb myuname mypass |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Reference an existing Schema of any kind, and provide some connection information for ->config: |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
script/myapp_create.pl model CatalystModelName DBIC::Schema \ |
130
|
|
|
|
|
|
|
MyApp::SchemaClass dbi:mysql:foodb myuname mypass |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Same, but don't supply connect information yet (you'll need to do this |
133
|
|
|
|
|
|
|
in your app config, or [not recommended] in the schema itself). |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
script/myapp_create.pl model ModelName DBIC::Schema My::SchemaClass |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
has helper => (is => 'ro', isa => 'Catalyst::Helper', required => 1); |
140
|
|
|
|
|
|
|
has create => (is => 'rw', isa => CreateOption); |
141
|
|
|
|
|
|
|
has args => (is => 'ro', isa => ArrayRef); |
142
|
|
|
|
|
|
|
has traits => (is => 'rw', isa => ArrayRef); |
143
|
|
|
|
|
|
|
has schema_class => (is => 'ro', isa => Str, required => 1); |
144
|
|
|
|
|
|
|
has loader_args => (is => 'rw', isa => HashRef); |
145
|
|
|
|
|
|
|
has connect_info => (is => 'rw', isa => HashRef); |
146
|
|
|
|
|
|
|
has old_schema => (is => 'rw', isa => Bool, lazy_build => 1); |
147
|
|
|
|
|
|
|
has is_moose_schema => (is => 'rw', isa => Bool, lazy_build => 1); |
148
|
|
|
|
|
|
|
has result_namespace => (is => 'rw', isa => Str, lazy_build => 1); |
149
|
|
|
|
|
|
|
has components => (is => 'rw', isa => ArrayRef); |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 METHODS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 mk_compclass |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This is called by L<Catalyst::Helper> with the commandline args to generate the |
156
|
|
|
|
|
|
|
files. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub mk_compclass { |
161
|
0
|
|
|
0
|
1
|
|
my ($package, $helper, $schema_class, @args) = @_; |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
my $self = $package->new( |
164
|
|
|
|
|
|
|
helper => $helper, |
165
|
|
|
|
|
|
|
schema_class => $schema_class, |
166
|
|
|
|
|
|
|
args => \@args |
167
|
|
|
|
|
|
|
); |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
$self->run; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub BUILD { |
173
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
174
|
0
|
|
|
|
|
|
my $helper = $self->helper; |
175
|
0
|
0
|
|
|
|
|
my @args = @{ $self->args || [] }; |
|
0
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
$helper->{schema_class} = $self->schema_class; |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
@args = $self->_cleanup_args(\@args); |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
my ($traits_idx, $traits); |
182
|
0
|
0
|
|
0
|
|
|
if (($traits_idx = firstidx { ($traits) = /^traits=(\S*)\z/ } @args) != -1) { |
|
0
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
my @traits = split /,/ => $traits; |
184
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
$self->traits(\@traits); |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
$helper->{traits} = '[' |
188
|
0
|
|
|
|
|
|
.(join ',' => map { qq{'$_'} } @traits) |
|
0
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
.']'; |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
splice @args, $traits_idx, 1, (); |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
0
|
0
|
0
|
|
|
|
if ($args[0] && $args[0] =~ /^create=(\S*)\z/) { |
195
|
0
|
|
|
|
|
|
$self->create($1); |
196
|
0
|
|
|
|
|
|
shift @args; |
197
|
|
|
|
|
|
|
|
198
|
0
|
0
|
|
|
|
|
if (@args) { |
199
|
0
|
|
|
|
|
|
$self->_parse_loader_args(\@args); |
200
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
$helper->{loader_args} = $self->_build_helper_loader_args; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
|
my $dbi_dsn_part; |
206
|
0
|
0
|
|
0
|
|
|
if (first { ($dbi_dsn_part) = /^(dbi):/i } @args) { |
|
0
|
|
|
|
|
|
|
207
|
0
|
0
|
|
|
|
|
die |
208
|
|
|
|
|
|
|
qq{DSN must start with 'dbi:' not '$dbi_dsn_part' (case matters!)} |
209
|
|
|
|
|
|
|
if $dbi_dsn_part ne 'dbi'; |
210
|
|
|
|
|
|
|
|
211
|
0
|
|
|
|
|
|
$helper->{setup_connect_info} = 1; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
$helper->{connect_info} = |
214
|
0
|
|
|
|
|
|
$self->_build_helper_connect_info(\@args); |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
$self->_parse_connect_info(\@args); |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
$helper->{generator} = ref $self; |
220
|
0
|
|
|
|
|
|
$helper->{generator_version} = $VERSION; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 run |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Can be called on an instance to generate the files. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=cut |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub run { |
230
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
231
|
|
|
|
|
|
|
|
232
|
0
|
0
|
|
|
|
|
if ($self->create eq 'dynamic') { |
|
|
0
|
|
|
|
|
|
233
|
0
|
|
|
|
|
|
$self->_print_dynamic_deprecation_warning; |
234
|
0
|
|
|
|
|
|
$self->_gen_dynamic_schema; |
235
|
|
|
|
|
|
|
} elsif ($self->create eq 'static') { |
236
|
0
|
|
|
|
|
|
$self->_gen_static_schema; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
$self->_gen_model; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub _parse_loader_args { |
243
|
0
|
|
|
0
|
|
|
my ($self, $args) = @_; |
244
|
|
|
|
|
|
|
|
245
|
0
|
|
|
|
|
|
my %loader_args = $self->_read_loader_args($args); |
246
|
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
|
while (my ($key, $val) = each %loader_args) { |
248
|
0
|
0
|
|
|
|
|
next if $key =~ /^(?:components|constraint|exclude)\z/; |
249
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
|
$loader_args{$key} = $self->_eval($val); |
251
|
0
|
0
|
|
|
|
|
die "syntax error for loader args key '$key' with value '$val': $@" |
252
|
|
|
|
|
|
|
if $@; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
my @components = $self->_build_loader_components( |
256
|
|
|
|
|
|
|
delete $loader_args{components}, |
257
|
|
|
|
|
|
|
$loader_args{use_namespaces}, |
258
|
0
|
|
|
|
|
|
); |
259
|
|
|
|
|
|
|
|
260
|
0
|
|
|
|
|
|
$self->components(\@components); |
261
|
|
|
|
|
|
|
|
262
|
0
|
|
|
|
|
|
for my $re_opt (qw/constraint exclude/) { |
263
|
|
|
|
|
|
|
$loader_args{$re_opt} = qr/$loader_args{$re_opt}/ |
264
|
0
|
0
|
|
|
|
|
if exists $loader_args{$re_opt}; |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
0
|
|
|
|
|
|
tie my %result, 'Tie::IxHash'; |
268
|
|
|
|
|
|
|
|
269
|
0
|
0
|
|
|
|
|
%result = ( |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
270
|
|
|
|
|
|
|
relationships => 1, |
271
|
|
|
|
|
|
|
use_moose => $self->is_moose_schema ? 1 : 0, |
272
|
|
|
|
|
|
|
col_collision_map => 'column_%s', |
273
|
|
|
|
|
|
|
(!$self->old_schema ? ( |
274
|
|
|
|
|
|
|
use_namespaces => 1 |
275
|
|
|
|
|
|
|
) : ()), |
276
|
|
|
|
|
|
|
(@components ? ( |
277
|
|
|
|
|
|
|
components => \@components |
278
|
|
|
|
|
|
|
) : ()), |
279
|
|
|
|
|
|
|
(%loader_args ? %loader_args : ()), |
280
|
|
|
|
|
|
|
); |
281
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
|
$self->loader_args(\%result); |
283
|
|
|
|
|
|
|
|
284
|
0
|
0
|
|
|
|
|
wantarray ? %result : \%result; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub _read_loader_args { |
288
|
0
|
|
|
0
|
|
|
my ($self, $args) = @_; |
289
|
|
|
|
|
|
|
|
290
|
0
|
|
|
|
|
|
my %loader_args; |
291
|
|
|
|
|
|
|
|
292
|
0
|
|
0
|
|
|
|
while (@$args && $args->[0] !~ /^dbi:/i) { |
293
|
0
|
|
|
|
|
|
my ($key, $val) = split /=/, shift(@$args), 2; |
294
|
|
|
|
|
|
|
|
295
|
0
|
0
|
|
|
|
|
if ($self->_is_struct($val)) { |
|
|
0
|
|
|
|
|
|
296
|
0
|
|
|
|
|
|
$loader_args{$key} = $val; |
297
|
|
|
|
|
|
|
} elsif ((my @vals = split /,/ => $val) > 1) { |
298
|
0
|
|
|
|
|
|
$loader_args{$key} = \@vals; |
299
|
|
|
|
|
|
|
} else { |
300
|
0
|
|
|
|
|
|
$loader_args{$key} = $val; |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
# Use args after connect_info as loader args as well, because people always |
305
|
|
|
|
|
|
|
# get the order confused. |
306
|
0
|
|
|
|
|
|
my $i = 1; |
307
|
0
|
0
|
|
|
|
|
if ($args->[0] =~ /sqlite/i) { |
308
|
0
|
0
|
|
|
|
|
$i++ if $args->[$i] eq ''; |
309
|
0
|
0
|
|
|
|
|
$i++ if $args->[$i] eq ''; |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
else { |
312
|
0
|
|
|
|
|
|
$i += 2; |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
my $have_loader = try { |
316
|
0
|
|
|
0
|
|
|
use_module('DBIx::Class::Schema::Loader::Base'); |
317
|
0
|
|
|
|
|
|
1; |
318
|
0
|
|
|
|
|
|
}; |
319
|
|
|
|
|
|
|
|
320
|
0
|
0
|
|
|
|
|
if ($have_loader) { |
321
|
0
|
|
|
|
|
|
while (defined $args->[$i]) { |
322
|
0
|
|
|
|
|
|
$i++ while $self->_is_struct($args->[$i]); |
323
|
|
|
|
|
|
|
|
324
|
0
|
0
|
|
|
|
|
last if not defined $args->[$i]; |
325
|
|
|
|
|
|
|
|
326
|
0
|
|
|
|
|
|
my ($key, $val) = split /=/, $args->[$i], 2; |
327
|
|
|
|
|
|
|
|
328
|
0
|
0
|
|
|
|
|
if (not DBIx::Class::Schema::Loader::Base->can($key)) { |
329
|
0
|
|
|
|
|
|
$i++; |
330
|
0
|
|
|
|
|
|
next; |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
|
333
|
0
|
0
|
|
|
|
|
if ($self->_is_struct($val)) { |
|
|
0
|
|
|
|
|
|
334
|
0
|
|
|
|
|
|
$loader_args{$key} = $val; |
335
|
|
|
|
|
|
|
} elsif ((my @vals = split /,/ => $val) > 1) { |
336
|
0
|
|
|
|
|
|
$loader_args{$key} = \@vals; |
337
|
|
|
|
|
|
|
} else { |
338
|
0
|
|
|
|
|
|
$loader_args{$key} = $val; |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
|
341
|
0
|
|
|
|
|
|
splice @$args, $i, 1; |
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
0
|
0
|
|
|
|
|
wantarray ? %loader_args : \%loader_args; |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
sub _build_helper_loader_args { |
349
|
0
|
|
|
0
|
|
|
my $self = shift; |
350
|
|
|
|
|
|
|
|
351
|
0
|
|
|
|
|
|
my $args = $self->loader_args; |
352
|
|
|
|
|
|
|
|
353
|
0
|
|
|
|
|
|
tie my %loader_args, 'Tie::IxHash'; |
354
|
|
|
|
|
|
|
|
355
|
0
|
|
|
|
|
|
while (my ($arg, $val) = each %$args) { |
356
|
0
|
0
|
|
|
|
|
if (ref $val) { |
357
|
0
|
|
|
|
|
|
$loader_args{$arg} = $self->_data_struct_to_string($val); |
358
|
|
|
|
|
|
|
} else { |
359
|
0
|
|
|
|
|
|
$loader_args{$arg} = qq{'$val'}; |
360
|
|
|
|
|
|
|
} |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
|
363
|
0
|
|
|
|
|
|
\%loader_args |
364
|
|
|
|
|
|
|
} |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
sub _build_loader_components { |
367
|
0
|
|
|
0
|
|
|
my ($self, $components, $use_namespaces) = @_; |
368
|
|
|
|
|
|
|
|
369
|
0
|
0
|
0
|
|
|
|
my @components = $self->old_schema && (not $use_namespaces) ? () |
370
|
|
|
|
|
|
|
: ('InflateColumn::DateTime'); |
371
|
|
|
|
|
|
|
|
372
|
0
|
0
|
|
|
|
|
if ($components) { |
373
|
0
|
0
|
|
|
|
|
$components = [ $components ] if !ref $components; |
374
|
0
|
|
|
|
|
|
push @components, @$components; |
375
|
|
|
|
|
|
|
} |
376
|
|
|
|
|
|
|
|
377
|
0
|
0
|
|
|
|
|
wantarray ? @components : \@components; |
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
sub _build_helper_connect_info { |
381
|
0
|
|
|
0
|
|
|
my ($self, $connect_info) = @_; |
382
|
|
|
|
|
|
|
|
383
|
0
|
|
|
|
|
|
my @connect_info = @$connect_info; |
384
|
|
|
|
|
|
|
|
385
|
0
|
|
|
|
|
|
my ($dsn, $user, $password) = $self->_get_dsn_user_pass(\@connect_info); |
386
|
|
|
|
|
|
|
|
387
|
0
|
|
|
|
|
|
tie my %helper_connect_info, 'Tie::IxHash'; |
388
|
|
|
|
|
|
|
|
389
|
0
|
|
|
|
|
|
%helper_connect_info = ( |
390
|
|
|
|
|
|
|
dsn => qq{'$dsn'}, |
391
|
|
|
|
|
|
|
user => qq{'$user'}, |
392
|
|
|
|
|
|
|
password => qq{'$password'} |
393
|
|
|
|
|
|
|
); |
394
|
|
|
|
|
|
|
|
395
|
0
|
|
|
|
|
|
for (@connect_info) { |
396
|
0
|
0
|
|
|
|
|
if (/^\s*{.*}\s*\z/) { |
397
|
0
|
|
|
|
|
|
my $hash = $self->_eval($_); |
398
|
0
|
0
|
|
|
|
|
die "Syntax errorr in connect_info hash: $_: $@" if $@; |
399
|
0
|
|
|
|
|
|
my %hash = %$hash; |
400
|
|
|
|
|
|
|
|
401
|
0
|
|
|
|
|
|
for my $key (keys %hash) { |
402
|
0
|
|
|
|
|
|
my $val = $hash{$key}; |
403
|
|
|
|
|
|
|
|
404
|
0
|
0
|
|
|
|
|
if (ref $val) { |
405
|
0
|
|
|
|
|
|
$val = $self->_data_struct_to_string($val); |
406
|
|
|
|
|
|
|
} else { |
407
|
0
|
|
|
|
|
|
$val = $self->_quote($val); |
408
|
|
|
|
|
|
|
} |
409
|
|
|
|
|
|
|
|
410
|
0
|
|
|
|
|
|
$helper_connect_info{$key} = $val; |
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
|
413
|
0
|
|
|
|
|
|
next; |
414
|
|
|
|
|
|
|
} |
415
|
|
|
|
|
|
|
|
416
|
0
|
|
|
|
|
|
my ($key, $val) = split /=/, $_, 2; |
417
|
|
|
|
|
|
|
|
418
|
0
|
0
|
|
|
|
|
if ($key eq 'quote_char') { |
419
|
0
|
0
|
|
|
|
|
$helper_connect_info{$key} = length($val) == 1 ? |
420
|
|
|
|
|
|
|
$self->_quote($val) : |
421
|
|
|
|
|
|
|
$self->_data_struct_to_string([split //, $val]); |
422
|
|
|
|
|
|
|
} else { |
423
|
0
|
|
|
|
|
|
$helper_connect_info{$key} = $self->_quote_unless_struct($val); |
424
|
|
|
|
|
|
|
} |
425
|
|
|
|
|
|
|
} |
426
|
|
|
|
|
|
|
|
427
|
0
|
|
|
|
|
|
\%helper_connect_info |
428
|
|
|
|
|
|
|
} |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
sub _build_old_schema { |
431
|
0
|
|
|
0
|
|
|
my $self = shift; |
432
|
|
|
|
|
|
|
|
433
|
0
|
0
|
|
|
|
|
return $self->result_namespace eq '' ? 1 : 0; |
434
|
|
|
|
|
|
|
} |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
sub _build_is_moose_schema { |
437
|
0
|
|
|
0
|
|
|
my $self = shift; |
438
|
|
|
|
|
|
|
|
439
|
0
|
|
|
|
|
|
my @schema_parts = split '::', $self->schema_class; |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
my $result_dir = File::Spec->catfile( |
442
|
0
|
|
|
|
|
|
$self->helper->{base}, 'lib', @schema_parts, $self->result_namespace |
443
|
|
|
|
|
|
|
); |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
# assume yes for new schemas |
446
|
0
|
0
|
|
|
|
|
return 1 if not -d $result_dir; |
447
|
|
|
|
|
|
|
|
448
|
0
|
|
|
|
|
|
my $uses_moose = 1; |
449
|
|
|
|
|
|
|
|
450
|
0
|
|
|
|
|
|
my $cwd = getcwd; |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
try { |
453
|
|
|
|
|
|
|
finddepth(sub { |
454
|
0
|
0
|
|
|
|
|
return if $File::Find::name !~ /\.pm\z/; |
455
|
|
|
|
|
|
|
|
456
|
0
|
0
|
|
|
|
|
open my $fh, '<', $File::Find::name |
457
|
|
|
|
|
|
|
or die "Could not open $File::Find::name: $!"; |
458
|
|
|
|
|
|
|
|
459
|
0
|
|
|
|
|
|
my $code = do { local $/; <$fh> }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
460
|
0
|
|
|
|
|
|
close $fh; |
461
|
|
|
|
|
|
|
|
462
|
0
|
0
|
|
|
|
|
$uses_moose = 0 if $code !~ /\nuse Moose;\n/; |
463
|
|
|
|
|
|
|
|
464
|
0
|
|
|
|
|
|
die; |
465
|
0
|
|
|
0
|
|
|
}, $result_dir); |
466
|
0
|
|
|
|
|
|
}; |
467
|
|
|
|
|
|
|
|
468
|
0
|
|
|
|
|
|
chdir $cwd; |
469
|
|
|
|
|
|
|
|
470
|
0
|
|
|
|
|
|
return $uses_moose; |
471
|
|
|
|
|
|
|
} |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
sub _build_result_namespace { |
474
|
0
|
|
|
0
|
|
|
my $self = shift; |
475
|
|
|
|
|
|
|
|
476
|
0
|
|
|
|
|
|
my @schema_parts = split '::', $self->schema_class; |
477
|
|
|
|
|
|
|
my $schema_pm = |
478
|
0
|
|
|
|
|
|
File::Spec->catfile($self->helper->{base}, 'lib', @schema_parts) . '.pm'; |
479
|
|
|
|
|
|
|
|
480
|
0
|
0
|
|
|
|
|
if (not -f $schema_pm) { |
481
|
0
|
|
|
|
|
|
eval { use_module('DBIx::Class::Schema::Loader') }; |
|
0
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
|
483
|
0
|
0
|
|
|
|
|
return 'Result' if $@; |
484
|
|
|
|
|
|
|
|
485
|
0
|
0
|
|
0
|
|
|
return (try { DBIx::Class::Schema::Loader->VERSION('0.05') }) ? 'Result' : ''; |
|
0
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
} |
487
|
|
|
|
|
|
|
|
488
|
0
|
0
|
|
|
|
|
open my $fh, '<', $schema_pm or die "Could not open $schema_pm: $!"; |
489
|
0
|
|
|
|
|
|
my $code = do { local $/; <$fh> }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
490
|
0
|
|
|
|
|
|
close $fh; |
491
|
|
|
|
|
|
|
|
492
|
0
|
|
|
|
|
|
my ($result_namespace) = $code =~ /result_namespace => '([^']+)'/; |
493
|
|
|
|
|
|
|
|
494
|
0
|
0
|
|
|
|
|
return $result_namespace if $result_namespace; |
495
|
|
|
|
|
|
|
|
496
|
0
|
0
|
|
|
|
|
return '' if $code =~ /->load_classes/; |
497
|
|
|
|
|
|
|
|
498
|
0
|
|
|
|
|
|
return 'Result'; |
499
|
|
|
|
|
|
|
} |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
sub _data_struct_to_string { |
502
|
0
|
|
|
0
|
|
|
my ($self, $data) = @_; |
503
|
|
|
|
|
|
|
|
504
|
0
|
|
|
|
|
|
local $Data::Dumper::Terse = 1; |
505
|
0
|
|
|
|
|
|
local $Data::Dumper::Quotekeys = 0; |
506
|
0
|
|
|
|
|
|
local $Data::Dumper::Sortkeys = 1; |
507
|
0
|
|
|
|
|
|
local $Data::Dumper::Indent = 0; |
508
|
0
|
|
|
|
|
|
local $Data::Dumper::Useqq = 1; |
509
|
|
|
|
|
|
|
|
510
|
0
|
|
|
|
|
|
return Data::Dumper->Dump([$data]); |
511
|
|
|
|
|
|
|
} |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
sub _get_dsn_user_pass { |
514
|
0
|
|
|
0
|
|
|
my ($self, $connect_info) = @_; |
515
|
|
|
|
|
|
|
|
516
|
0
|
|
|
|
|
|
my $dsn = shift @$connect_info; |
517
|
0
|
|
|
|
|
|
my ($user, $password); |
518
|
|
|
|
|
|
|
|
519
|
0
|
0
|
|
|
|
|
if ($dsn =~ /sqlite/i) { |
520
|
0
|
|
|
|
|
|
($user, $password) = ('', ''); |
521
|
0
|
|
0
|
|
|
|
shift @$connect_info while @$connect_info and $connect_info->[0] eq ''; |
522
|
|
|
|
|
|
|
} else { |
523
|
0
|
|
|
|
|
|
($user, $password) = splice @$connect_info, 0, 2; |
524
|
|
|
|
|
|
|
} |
525
|
|
|
|
|
|
|
|
526
|
0
|
|
|
|
|
|
($dsn, $user, $password) |
527
|
|
|
|
|
|
|
} |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
sub _parse_connect_info { |
530
|
0
|
|
|
0
|
|
|
my ($self, $connect_info) = @_; |
531
|
|
|
|
|
|
|
|
532
|
0
|
|
|
|
|
|
my @connect_info = @$connect_info; |
533
|
|
|
|
|
|
|
|
534
|
0
|
|
|
|
|
|
my ($dsn, $user, $password) = $self->_get_dsn_user_pass(\@connect_info); |
535
|
|
|
|
|
|
|
|
536
|
0
|
|
|
|
|
|
tie my %connect_info, 'Tie::IxHash'; |
537
|
0
|
|
|
|
|
|
@connect_info{qw/dsn user password/} = ($dsn, $user, $password); |
538
|
|
|
|
|
|
|
|
539
|
0
|
|
|
|
|
|
for (@connect_info) { |
540
|
0
|
0
|
|
|
|
|
if (/^\s*{.*}\s*\z/) { |
541
|
0
|
|
|
|
|
|
my $hash = $self->_eval($_); |
542
|
0
|
0
|
|
|
|
|
die "Syntax errorr in connect_info hash: $_: $@" if $@; |
543
|
|
|
|
|
|
|
|
544
|
0
|
|
|
|
|
|
%connect_info = (%connect_info, %$hash); |
545
|
|
|
|
|
|
|
|
546
|
0
|
|
|
|
|
|
next; |
547
|
|
|
|
|
|
|
} |
548
|
|
|
|
|
|
|
|
549
|
0
|
|
|
|
|
|
my ($key, $val) = split /=/, $_, 2; |
550
|
|
|
|
|
|
|
|
551
|
0
|
0
|
|
|
|
|
if ($key eq 'quote_char') { |
|
|
0
|
|
|
|
|
|
552
|
0
|
0
|
|
|
|
|
$connect_info{$key} = length($val) == 1 ? $val : [split //, $val]; |
553
|
|
|
|
|
|
|
} elsif ($key =~ /^(?:name_sep|limit_dialect)\z/) { |
554
|
0
|
|
|
|
|
|
$connect_info{$key} = $val; |
555
|
|
|
|
|
|
|
} else { |
556
|
0
|
|
|
|
|
|
$connect_info{$key} = $self->_eval($val); |
557
|
|
|
|
|
|
|
} |
558
|
|
|
|
|
|
|
|
559
|
0
|
0
|
|
|
|
|
die "syntax error for connect_info key '$key' with value '$val': $@" |
560
|
|
|
|
|
|
|
if $@; |
561
|
|
|
|
|
|
|
} |
562
|
|
|
|
|
|
|
|
563
|
0
|
|
|
|
|
|
$self->connect_info(\%connect_info); |
564
|
|
|
|
|
|
|
|
565
|
0
|
|
|
|
|
|
\%connect_info |
566
|
|
|
|
|
|
|
} |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
sub _is_struct { |
569
|
0
|
|
|
0
|
|
|
my ($self, $val) = @_; |
570
|
|
|
|
|
|
|
|
571
|
0
|
|
|
|
|
|
return $val =~ /^\s*(?:sub|[[{])/; |
572
|
|
|
|
|
|
|
} |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
sub _quote { |
575
|
0
|
|
|
0
|
|
|
my ($self, $val) = @_; |
576
|
|
|
|
|
|
|
|
577
|
0
|
|
|
|
|
|
return 'q{'.$val.'}'; |
578
|
|
|
|
|
|
|
} |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
sub _quote_unless_struct { |
581
|
0
|
|
|
0
|
|
|
my ($self, $val) = @_; |
582
|
|
|
|
|
|
|
|
583
|
0
|
0
|
|
|
|
|
$val = $self->_quote($val) if not $self->_is_struct($val); |
584
|
|
|
|
|
|
|
|
585
|
0
|
|
|
|
|
|
return $val; |
586
|
|
|
|
|
|
|
} |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
sub _eval { |
589
|
0
|
|
|
0
|
|
|
my ($self, $code) = @_; |
590
|
|
|
|
|
|
|
|
591
|
0
|
0
|
|
|
|
|
return $code if looks_like_number $code; |
592
|
|
|
|
|
|
|
|
593
|
0
|
0
|
|
|
|
|
return $code if not $self->_is_struct($code); |
594
|
|
|
|
|
|
|
|
595
|
0
|
|
|
|
|
|
return eval "{no strict; $code}"; |
596
|
|
|
|
|
|
|
} |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
sub _gen_dynamic_schema { |
599
|
0
|
|
|
0
|
|
|
my $self = shift; |
600
|
|
|
|
|
|
|
|
601
|
0
|
|
|
|
|
|
my $helper = $self->helper; |
602
|
|
|
|
|
|
|
|
603
|
0
|
|
|
|
|
|
my @schema_parts = split(/\:\:/, $self->schema_class); |
604
|
0
|
|
|
|
|
|
my $schema_file_part = pop @schema_parts; |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
my $schema_dir = File::Spec->catfile( |
607
|
0
|
|
|
|
|
|
$helper->{base}, 'lib', @schema_parts |
608
|
|
|
|
|
|
|
); |
609
|
0
|
|
|
|
|
|
my $schema_file = File::Spec->catfile( |
610
|
|
|
|
|
|
|
$schema_dir, $schema_file_part . '.pm' |
611
|
|
|
|
|
|
|
); |
612
|
|
|
|
|
|
|
|
613
|
0
|
|
|
|
|
|
$helper->mk_dir($schema_dir); |
614
|
0
|
|
|
|
|
|
$helper->render_file('schemaclass', $schema_file); |
615
|
|
|
|
|
|
|
} |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
sub _gen_static_schema { |
618
|
0
|
|
|
0
|
|
|
my $self = shift; |
619
|
|
|
|
|
|
|
|
620
|
0
|
0
|
|
|
|
|
die "cannot load schema without connect info" unless $self->connect_info; |
621
|
|
|
|
|
|
|
|
622
|
0
|
|
|
|
|
|
my $helper = $self->helper; |
623
|
|
|
|
|
|
|
|
624
|
0
|
|
|
|
|
|
my $schema_dir = File::Spec->catfile($helper->{base}, 'lib'); |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
try { |
627
|
0
|
|
|
0
|
|
|
use_module('DBIx::Class::Schema::Loader') |
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
catch { |
630
|
0
|
|
|
0
|
|
|
die "Cannot load DBIx::Class::Schema::Loader: $_"; |
631
|
0
|
|
|
|
|
|
}; |
632
|
|
|
|
|
|
|
|
633
|
0
|
|
|
|
|
|
DBIx::Class::Schema::Loader->import( |
634
|
|
|
|
|
|
|
"dump_to_dir:$schema_dir", 'make_schema_at' |
635
|
|
|
|
|
|
|
); |
636
|
|
|
|
|
|
|
|
637
|
0
|
|
|
|
|
|
make_schema_at( |
638
|
|
|
|
|
|
|
$self->schema_class, |
639
|
|
|
|
|
|
|
$self->loader_args, |
640
|
|
|
|
|
|
|
[$self->connect_info] |
641
|
|
|
|
|
|
|
); |
642
|
|
|
|
|
|
|
|
643
|
0
|
|
|
|
|
|
require lib; |
644
|
0
|
|
|
|
|
|
lib->import($schema_dir); |
645
|
|
|
|
|
|
|
|
646
|
0
|
|
|
|
|
|
use_module($self->schema_class); |
647
|
|
|
|
|
|
|
|
648
|
0
|
|
|
|
|
|
my @sources = $self->schema_class->sources; |
649
|
|
|
|
|
|
|
|
650
|
0
|
0
|
|
|
|
|
if (not @sources) { |
651
|
0
|
|
|
|
|
|
warn <<'EOF'; |
652
|
|
|
|
|
|
|
WARNING: No tables found, did you forget to specify db_schema? |
653
|
|
|
|
|
|
|
EOF |
654
|
|
|
|
|
|
|
} |
655
|
|
|
|
|
|
|
} |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
sub _gen_model { |
658
|
0
|
|
|
0
|
|
|
my $self = shift; |
659
|
0
|
|
|
|
|
|
my $helper = $self->helper; |
660
|
|
|
|
|
|
|
|
661
|
0
|
|
|
|
|
|
$helper->render_file('compclass', $helper->{file} ); |
662
|
|
|
|
|
|
|
} |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
sub _print_dynamic_deprecation_warning { |
665
|
0
|
|
|
0
|
|
|
warn <<EOF; |
666
|
|
|
|
|
|
|
************************************ WARNING ********************************** |
667
|
|
|
|
|
|
|
* create=dynamic is DEPRECATED, please use create=static instead. * |
668
|
|
|
|
|
|
|
******************************************************************************* |
669
|
|
|
|
|
|
|
EOF |
670
|
0
|
|
|
|
|
|
print "Continue? [y/n]: "; |
671
|
0
|
|
|
|
|
|
chomp(my $response = <STDIN>); |
672
|
0
|
0
|
|
|
|
|
exit 0 if $response =~ /^n(o)?\z/; |
673
|
|
|
|
|
|
|
} |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
sub _cleanup_args { |
676
|
0
|
|
|
0
|
|
|
my ($self, $args) = @_; |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
# remove blanks, ie. someoned doing foo \ bar |
679
|
0
|
|
|
|
|
|
my @res = grep !/^\s+\z/, @$args; |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
# remove leading whitespace, ie. foo \ bar |
682
|
0
|
|
|
|
|
|
s/^\s*// for @res; |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
@res |
685
|
0
|
|
|
|
|
|
} |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
=head1 SEE ALSO |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
General Catalyst Stuff: |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>, |
692
|
|
|
|
|
|
|
L<Catalyst::Response>, L<Catalyst::Helper>, L<Catalyst>, |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
Stuff related to DBIC and this Model style: |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
L<DBIx::Class>, L<DBIx::Class::Schema>, |
697
|
|
|
|
|
|
|
L<DBIx::Class::Schema::Loader>, L<Catalyst::Model::DBIC::Schema> |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
=head1 AUTHOR |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
See L<Catalyst::Model::DBIC::Schema/AUTHOR> and |
702
|
|
|
|
|
|
|
L<Catalyst::Model::DBIC::Schema/CONTRIBUTORS>. |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
=head1 COPYRIGHT |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
See L<Catalyst::Model::DBIC::Schema/COPYRIGHT>. |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
=head1 LICENSE |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify |
711
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
=cut |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
1; |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
__DATA__ |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
=begin pod_to_ignore |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
__schemaclass__ |
722
|
|
|
|
|
|
|
package [% schema_class %]; |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
use strict; |
725
|
|
|
|
|
|
|
use base qw/DBIx::Class::Schema::Loader/; |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
__PACKAGE__->loader_options( |
728
|
|
|
|
|
|
|
[%- FOREACH key = loader_args.keys %] |
729
|
|
|
|
|
|
|
[% key %] => [% loader_args.${key} %], |
730
|
|
|
|
|
|
|
[%- END -%] |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
); |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
=head1 NAME |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
[% schema_class %] - L<DBIx::Class::Schema::Loader> class |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
=head1 SYNOPSIS |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
See L<[% app %]> |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
=head1 DESCRIPTION |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
Dynamic L<DBIx::Class::Schema::Loader> schema for use in L<[% class %]> |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
=head1 GENERATED BY |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
[% generator %] - [% generator_version %] |
749
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
=head1 AUTHOR |
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
[% author.replace(',+$', '') %] |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
=head1 LICENSE |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify |
757
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
=cut |
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
1; |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
__compclass__ |
764
|
|
|
|
|
|
|
package [% class %]; |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
use strict; |
767
|
|
|
|
|
|
|
use base 'Catalyst::Model::DBIC::Schema'; |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
__PACKAGE__->config( |
770
|
|
|
|
|
|
|
schema_class => '[% schema_class %]', |
771
|
|
|
|
|
|
|
[% IF traits %]traits => [% traits %],[% END %] |
772
|
|
|
|
|
|
|
[% IF setup_connect_info %]connect_info => { |
773
|
|
|
|
|
|
|
[%- FOREACH key = connect_info.keys %] |
774
|
|
|
|
|
|
|
[% key %] => [% connect_info.${key} %], |
775
|
|
|
|
|
|
|
[%- END -%] |
776
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
}[% END %] |
778
|
|
|
|
|
|
|
); |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
=head1 NAME |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
[% class %] - Catalyst DBIC Schema Model |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
=head1 SYNOPSIS |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
See L<[% app %]> |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
=head1 DESCRIPTION |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
L<Catalyst::Model::DBIC::Schema> Model using schema L<[% schema_class %]> |
791
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
=head1 GENERATED BY |
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
[% generator %] - [% generator_version %] |
795
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
=head1 AUTHOR |
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
[% author.replace(',+$', '') %] |
799
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
=head1 LICENSE |
801
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify |
803
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
804
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
=cut |
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
1; |
808
|
|
|
|
|
|
|
__END__ |
809
|
|
|
|
|
|
|
# vim:sts=4 sw=4: |