From: Brandon L. Black Date: Thu, 6 Jul 2006 13:27:35 +0000 (+0000) Subject: fixed problem with create=static and connect_info code-snippet arguments X-Git-Tag: v0.16~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=592cd3ae2cba0785755131c4ed9ce04ced231d74;p=catagits%2FCatalyst-Model-DBIC-Schema.git fixed problem with create=static and connect_info code-snippet arguments --- diff --git a/lib/Catalyst/Helper/Model/DBIC/Schema.pm b/lib/Catalyst/Helper/Model/DBIC/Schema.pm index a2e6396..863715d 100644 --- a/lib/Catalyst/Helper/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Helper/Model/DBIC/Schema.pm @@ -73,7 +73,7 @@ sub mk_compclass { my ( $self, $helper, $schema_class, @connect_info) = @_; $helper->{schema_class} = $schema_class - or die "Must supply schema class name"; + or croak "Must supply schema class name"; my $create = ''; if($connect_info[0] && $connect_info[0] =~ /^create=(dynamic|static)$/) { @@ -101,14 +101,25 @@ sub mk_compclass { $helper->render_file( 'schemaclass', $schema_file ); } elsif($create eq 'static') { - my $schema_dir = File::Spec->catfile( $helper->{base}, 'lib' ); - DBIx::Class::Schema::Loader->use("dump_to_dir:$schema_dir", 'make_schema_at') - or die "Cannot load DBIx::Class::Schema::Loader: $@"; - make_schema_at( - $schema_class, - { relationships => 1 }, - \@connect_info, - ); + my $schema_dir = File::Spec->catfile( $helper->{base}, 'lib' ); + DBIx::Class::Schema::Loader->use("dump_to_dir:$schema_dir", 'make_schema_at') + or croak "Cannot load DBIx::Class::Schema::Loader: $@"; + + my @loader_connect_info = @connect_info; + my $num = 6; # argument number on the commandline for "dbi:..." + for(@loader_connect_info) { + if(/^\s*[[{]/) { + $_ = eval "$_"; + croak "Perl syntax error in commandline argument $num: $@" if $@; + } + $num++; + } + + make_schema_at( + $schema_class, + { relationships => 1 }, + \@loader_connect_info, + ); } my $file = $helper->{file};