From: Rafael Kitover Date: Wed, 11 May 2011 06:00:06 +0000 (+0000) Subject: fix ->isa check in Replicated trait, Model POD and SchemaProxy RS options X-Git-Tag: 0.50~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f24a5fbb99e2c3506d6aff1fa9f489a1dba7e383;p=catagits%2FCatalyst-Model-DBIC-Schema.git fix ->isa check in Replicated trait, Model POD and SchemaProxy RS options --- diff --git a/Changes b/Changes index 5df8166..9e21016 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,9 @@ Revision history for Perl extension Catalyst::Model::DBIC::Schema + - make sure storage_type class is loaded before ->isa check in + Replicated trait (RT#65791) - fix regex stringification test for perl 5.14 (RT#68098) + - update connect_info POD (RT#66010) 0.48 Thu Dec 9 21:08:33 UTC 2010 - fix usage of Try::Tiny in helper diff --git a/lib/Catalyst/Helper/Model/DBIC/Schema.pm b/lib/Catalyst/Helper/Model/DBIC/Schema.pm index e9cac2c..1c98a0f 100644 --- a/lib/Catalyst/Helper/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Helper/Model/DBIC/Schema.pm @@ -88,11 +88,7 @@ user and pass can be omitted for sqlite, since they are always empty script/myapp_create.pl model CatalystModelName DBIC::Schema \ MyApp::SchemaClass create=static dbi:SQLite:foo.db \ AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \ - on_connect_do='["select 1", "select 2"]' quote_char='"' - -If using a 2 character quote_char: - - script/myapp_create.pl ... quote_char='[]' + on_connect_do='["select 1", "select 2"]' quote_names=1 B @@ -101,7 +97,7 @@ In C the above example would be: script/myapp_create.pl model CatalystModelName DBIC::Schema \ MyApp::SchemaClass create=static dbi:SQLite:foo.db \ AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \ - on_connect_do="[\"select 1\", \"select 2\"]" quote_char="\"" + on_connect_do="[\"select 1\", \"select 2\"]" quote_names=1 Same, but with extra Schema::Loader args (separate multiple values by commas): diff --git a/lib/Catalyst/Model/DBIC/Schema.pm b/lib/Catalyst/Model/DBIC/Schema.pm index 493f38d..8dfe07c 100644 --- a/lib/Catalyst/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Model/DBIC/Schema.pm @@ -33,7 +33,7 @@ A typical usage of the helper script would be: script/myapp_create.pl model FilmDB DBIC::Schema MyApp::Schema::FilmDB \ create=static dbi:mysql:filmdb dbusername dbpass \ - quote_char='`' name_sep='.' + quote_names=1 If you are unfamiliar with L, see L first. @@ -169,13 +169,12 @@ C namespace. This parameter is required. =head2 connect_info -This is an arrayref of connection parameters, which are specific to your -C (see your storage type documentation for more details). -If you only need one parameter (e.g. the DSN), you can just pass a string -instead of an arrayref. +This is a hashref or arrayref of connection parameters, which are specific to +your C (see your storage type documentation for more details). If +you only need one parameter (e.g. the DSN), you can just pass a string. This is not required if C already has connection information -defined inside itself (which isn't highly recommended, but can be done) +defined inside itself (which isn't highly recommended, but can be done.) For L, which is the only supported C in L at the time of this writing, the @@ -220,7 +219,7 @@ Or using L: user postgres password "" auto_savepoint 1 - quote_char """ + quote_names 1 on_connect_do some SQL statement on_connect_do another SQL statement @@ -246,7 +245,7 @@ Or using L: LongReadLen: 1000000 LongTruncOk: 1 on_connect_call: 'datetime_setup' - quote_char: '"' + quote_names: 1 The old arrayref style with hashrefs for L then L options is also supported: diff --git a/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm b/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm index 5b38909..73317d8 100644 --- a/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm +++ b/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm @@ -88,6 +88,8 @@ after setup => sub { "DBIx::Class::Storage$storage_type" : $storage_type; + Class::MOP::load_class($class); + croak "This storage_type cannot be used with replication" unless $class->isa('DBIx::Class::Storage::DBI::Replicated'); } else { diff --git a/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm b/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm index 0f97e97..bba6279 100644 --- a/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm +++ b/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm @@ -165,19 +165,10 @@ sub _pass_options_to_schema { sub _pass_options_to_resultset { my ($self, $source, $args) = @_; - my @attributes = map { - $_->init_arg || () - } $self->meta->get_all_attributes; - - my %attributes; - @attributes{@attributes} = (); - for my $opt (keys %$args) { - if (not exists $attributes{$opt}) { - my $rs_class = $self->schema->source($source)->resultset_class; - next unless $rs_class->can($opt); - $rs_class->$opt($args->{$opt}); - } + my $rs_class = $self->schema->source($source)->resultset_class; + next unless $rs_class->can($opt); + $rs_class->$opt($args->{$opt}); } }