From: Tomas Doran Date: Wed, 29 Jul 2009 21:54:10 +0000 (+0000) Subject: Un fuck by reverse merge acrosss the entire repos - svn merge -r 10977:10972 . X-Git-Tag: v0.26~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=227854cca7c5779449af2cfce5e6a1d9ffc7760c;hp=2a969b063ea6ab41d6fde9b56d07a532ee80c3f0;p=catagits%2FCatalyst-Model-DBIC-Schema.git Un fuck by reverse merge acrosss the entire repos - svn merge -r 10977:10972 . --- diff --git a/Changes b/Changes index c07873f..d885aac 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for Perl extension Catalyst::Model::DBIC::Schema 0.26 As yet unreleased + - fix loading connect_info from schema-defined connection (RT 48084) - Fix missing dep on Catalyst::Helper that made tests fail (RT 47449) 0.25 Fri Jun 19 08:35:38 PDT 2009 diff --git a/lib/Catalyst/Helper/Model/DBIC/Schema.pm b/lib/Catalyst/Helper/Model/DBIC/Schema.pm index b078a33..4d01ea1 100644 --- a/lib/Catalyst/Helper/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Helper/Model/DBIC/Schema.pm @@ -189,7 +189,12 @@ sub BUILD { $helper->{loader_args} = $self->_build_helper_loader_args; - if (first { /^dbi:/i } @args) { + my $dbi_dsn_part; + if (first { ($dbi_dsn_part) = /^(dbi):/i } @args) { + die +qq{DSN must start with 'dbi:' not '$dbi_dsn_part' (case matters!)} + if $dbi_dsn_part ne 'dbi'; + $helper->{setup_connect_info} = 1; $helper->{connect_info} = @@ -269,7 +274,7 @@ sub _read_loader_args { my %loader_args; - while (@$args && $args->[0] !~ /^dbi:/) { + while (@$args && $args->[0] !~ /^dbi:/i) { my ($key, $val) = split /=/, shift(@$args), 2; if ($self->_is_struct($val)) { diff --git a/lib/Catalyst/Model/DBIC/Schema.pm b/lib/Catalyst/Model/DBIC/Schema.pm index dece52f..cfdb5e4 100644 --- a/lib/Catalyst/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Model/DBIC/Schema.pm @@ -442,7 +442,7 @@ has schema_class => ( has storage_type => (is => 'rw', isa => Str); -has connect_info => (is => 'ro', isa => ConnectInfo, coerce => 1); +has connect_info => (is => 'rw', isa => ConnectInfo, coerce => 1); has model_name => ( is => 'ro', diff --git a/t/07connect_info.t b/t/07connect_info.t index 0e0ed70..e49dba1 100644 --- a/t/07connect_info.t +++ b/t/07connect_info.t @@ -47,7 +47,7 @@ my @invalid = ( { pg_enable_utf8 => 1 }, { AutoCommit => 1 }, { auto_savepoint => 1 }], ); -plan tests => @tests / 2 + @invalid + 1; +plan tests => @tests / 2 + @invalid + 1 + 1; # ignore redefined warnings, and uninitialized warnings from old # ::Storage::DBI::Replicated @@ -88,6 +88,14 @@ is_deeply $m->replicants, [ map $tests[$_], grep $_ % 2, 0 .. $#tests ], 'replicant connect_infos coerced correctly'; +{ + ASchemaClass->connection( @{$tests[0]} ); + my $m = instance(); + + is_deeply $m->connect_info, $tests[1], + 'connect_info coerced correctly when defining connection in the schema class'; +} + sub instance { Catalyst::Model::DBIC::Schema->new({ schema_class => 'ASchemaClass', diff --git a/t/08helper.t b/t/08helper.t index e7b2a9d..066a69d 100644 --- a/t/08helper.t +++ b/t/08helper.t @@ -10,7 +10,7 @@ use Catalyst::Helper::Model::DBIC::Schema; use Storable 'dclone'; eval "use Catalyst::Helper"; plan skip_all => 'Catalyst::Helper required for tests' if $@; -plan tests => 40; +plan tests => 41; my $helper = Catalyst::Helper->new; $helper->{base} = $Bin; @@ -26,6 +26,9 @@ my $i; $i = instance(schema_class => 'ASchemaClass'); is $i->old_schema, 1, '->load_classes detected correctly'; +throws_ok { $i = instance(args => [$static, 'DbI:SQLite:myapp.db']) } + qr/case matters/i, "wrong case for 'dbi:' DSN part"; + $i = instance(args => ['traits=Caching']); is_deeply $i->traits, ['Caching'], 'one trait'; is $i->helper->{traits}, "['Caching']", 'one trait as string';