From: Rafael Kitover Date: Wed, 27 Jul 2011 20:58:02 +0000 (-0400) Subject: accept loader args after connect_info, release X-Git-Tag: v0.51^0 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Model-DBIC-Schema.git;a=commitdiff_plain;h=f1b4a8fde8a23ab98178c8b78c43eb0c14f52130 accept loader args after connect_info, release --- diff --git a/Changes b/Changes index c048478..e0c31d3 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for Perl extension Catalyst::Model::DBIC::Schema +0.51 Wed Jul 27 20:57:47 UTC 2011 - warn when helper finds no tables + - accept loader args after connect_info 0.50 Fri May 20 22:45:07 UTC 2011 - change repository link to the new git repo diff --git a/lib/Catalyst/Helper/Model/DBIC/Schema.pm b/lib/Catalyst/Helper/Model/DBIC/Schema.pm index b947be4..5062ec1 100644 --- a/lib/Catalyst/Helper/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Helper/Model/DBIC/Schema.pm @@ -4,7 +4,7 @@ use namespace::autoclean; use Moose; no warnings 'uninitialized'; -our $VERSION = '0.50'; +our $VERSION = '0.51'; $VERSION = eval $VERSION; use Carp; @@ -300,6 +300,29 @@ sub _read_loader_args { } } + # Use args after connect_info as loader args as well, because people always + # get the order confused. + my $i = 1; + if ($args->[0] =~ /sqlite/i) { + $i++ if $args->[$i] eq ''; + $i++ if $args->[$i] eq ''; + } + else { + $i += 2; + } + + while (defined $args->[$i]) { + my ($key, $val) = split /=/, $args->[$i++], 2; + + if ($self->_is_struct($val)) { + $loader_args{$key} = $val; + } elsif ((my @vals = split /,/ => $val) > 1) { + $loader_args{$key} = \@vals; + } else { + $loader_args{$key} = $val; + } + } + wantarray ? %loader_args : \%loader_args; } diff --git a/lib/Catalyst/Model/DBIC/Schema.pm b/lib/Catalyst/Model/DBIC/Schema.pm index 3b2cfc2..12a3185 100644 --- a/lib/Catalyst/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Model/DBIC/Schema.pm @@ -5,7 +5,7 @@ use mro 'c3'; extends 'Catalyst::Model'; with 'CatalystX::Component::Traits'; -our $VERSION = '0.50'; +our $VERSION = '0.51'; $VERSION = eval $VERSION; use namespace::autoclean; diff --git a/t/08helper.t b/t/08helper.t index 27df355..290553a 100644 --- a/t/08helper.t +++ b/t/08helper.t @@ -166,6 +166,15 @@ is $i->helper->{connect_info}{auto_savepoint}, 'q{1}', is $i->helper->{connect_info}{AutoCommit}, 'q{0}', 'connect_info arg from extra hash as string'; +$i = instance(args => [ + $static, 'components=TimeStamp', $sqlite, $on_connect_do, + $quote_char, $name_sep, 'auto_savepoint=1', 'AutoCommit=0', + 'db_schema=myschema', +]); + +is $i->loader_args->{db_schema}, 'myschema', + 'loader arg after connect_info'; + done_testing; sub instance {