X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FModel%2FDBIC%2FSchema.pm;h=710388a5f1e4469f38de655f681a7b80012bc756;hb=4bd6775c3865b9b941cf1a7c7bef4c6cadf5e4c8;hp=16d012ae0a667111840fbf89ac41e5e6f527f8b7;hpb=cd7e6e4f224c78645ba1ae5cc0bb336a8ea7c4e0;p=catagits%2FCatalyst-Model-DBIC-Schema.git diff --git a/lib/Catalyst/Model/DBIC/Schema.pm b/lib/Catalyst/Model/DBIC/Schema.pm index 16d012a..710388a 100644 --- a/lib/Catalyst/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Model/DBIC/Schema.pm @@ -6,7 +6,7 @@ use NEXT; use UNIVERSAL::require; use Carp; -our $VERSION = '0.10'; +our $VERSION = '0.11'; __PACKAGE__->mk_classaccessor('composed_schema'); __PACKAGE__->mk_accessors('schema'); @@ -27,8 +27,15 @@ Catalyst::Model::DBIC::Schema - DBIx::Class::Schema Model Class 'postgres', '', { AutoCommit => 1 }, + { limit_dialect => 'xxx', + quote_char => q{`}, + name_sep => q{@}, + on_connect_do => [ + 'sql statement 1', + 'sql statement 2', + ] + } ], - on_connect_do => [ 'sql statement 1', 'sql statement 2' ], ); 1; @@ -93,11 +100,6 @@ This is not required if C already has connection information defined in itself (which would be the case for a Schema defined by L, for instance). -=item on_connect_do - -This is an arrayref of sql statements, which are executed on every connect. -May not be a valid/useful argument with non-DBI-based Storages. - =item storage_type Allows the use of a different C than what is set in your @@ -191,13 +193,25 @@ sub new { $self->schema->storage_type($self->{storage_type}) if $self->{storage_type}; $self->schema->connection(@{$self->{connect_info}}); - $self->schema->storage->on_connect_do($self->{on_connect_do}) - if $self->{on_connect_do}; + + # This is temporary, until DBIx::Class supports the same syntax and we + # switch our requisite to that version somewhere down the line. + my $last_info = $self->{connect_info}->[-1]; + if(ref $last_info eq 'HASH') { + if(my $on_connect_do = $last_info->{on_connect_do}) { + $self->schema->storage->on_connect_do($self->{on_connect_do}); + } + foreach my $sql_maker_opt (qw/limit_dialect quote_char name_sep/) { + if(my $opt_val = $last_info->{$sql_maker_opt}) { + $self->schema->storage->sql_maker->$sql_maker_opt($opt_val); + } + } + } no strict 'refs'; foreach my $moniker ($self->schema->sources) { my $classname = "${class}::$moniker"; - *{"${classname}::ACCEPT_CONTEXT"} = sub { + *{"${classname}::COMPONENT"} = sub { shift; shift->model($model_name)->resultset($moniker); }