From: Norbert Csongradi Date: Mon, 18 Sep 2006 19:55:40 +0000 (+0200) Subject: Fixed limit_dialect docs, option passing. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=82aa2963a9fdea79abb2fb42cf970c4d3ee0f942;p=dbsrgits%2FDBIx-Class-Historic.git Fixed limit_dialect docs, option passing. --- diff --git a/lib/DBIx/Class/Storage/DBI/Replication.pm b/lib/DBIx/Class/Storage/DBI/Replication.pm index 791559f..76e86e2 100644 --- a/lib/DBIx/Class/Storage/DBI/Replication.pm +++ b/lib/DBIx/Class/Storage/DBI/Replication.pm @@ -21,12 +21,9 @@ DBIx::Class::Storage::DBI::Replication - Replicated database support [ "dbi:mysql:database=test;hostname=master", "username", "password", { AutoCommit => 1 } ], # master [ "dbi:mysql:database=test;hostname=slave1", "username", "password", { priority => 10 } ], # slave1 [ "dbi:mysql:database=test;hostname=slave2", "username", "password", { priority => 10 } ], # slave2 - <...> + <...>, + { limit_dialect => 'LimitXY' } # If needed, see below ] ); - # If you use LIMIT in your queries (effectively, if you use SQL::Abstract::Limit), - # do not forget to set up limit_dialect (see: perldoc SQL::Abstract::Limit) - # DBIC can not set it up automatically, since DBD::Multi could not be supported directly - $schema->limit_dialect( 'LimitXY' ) # For MySQL =head1 DESCRIPTION @@ -38,6 +35,13 @@ For every slave database you can define a priority value, which controls data so L, so first the lower priority data sources used (if they have the same priority, the are used randomized), than if all low priority data sources fail, higher ones tried in order. +=head1 CONFIGURATION + +=head2 Limit dialect + +If you use LIMIT in your queries (effectively, if you use SQL::Abstract::Limit), do not forget to set up limit_dialect (perldoc SQL::Abstract::Limit) by passing it as an option in the (optional) hash reference to connect_info. +DBIC can not set it up automatically, since it can not guess DBD::Multi connection types. + =cut sub new { @@ -64,10 +68,12 @@ sub all_sources { sub connect_info { my( $self, $source_info ) = @_; - $self->write_source->connect_info( $source_info->[0] ); + my $last_info = ref $source_info->[-1] eq 'HASH' ? pop( @$source_info ) : undef; + + $self->write_source->connect_info( $source_info->[0], $last_info ); my @dsns = map { ($_->[3]->{priority} || 10) => $_ } @{$source_info}[1..@$source_info-1]; - $self->read_source->connect_info( [ 'dbi:Multi:', undef, undef, { dsns => \@dsns } ] ); + $self->read_source->connect_info( [ 'dbi:Multi:', undef, undef, { dsns => \@dsns } ], $last_info ); } sub select {