1 package DBIx::Class::Storage::DBI::Replicated::WithDSN;
4 use Scalar::Util 'reftype';
5 requires qw/_query_start/;
8 use namespace::clean -except => 'meta';
12 DBIx::Class::Storage::DBI::Replicated::WithDSN - A DBI Storage Role with DSN
13 information in trace output
17 This class is used internally by L<DBIx::Class::Storage::DBI::Replicated>.
21 This role adds C<DSN: > info to storage debugging output.
25 This class defines the following methods.
27 =head2 around: _query_start
29 Add C<DSN: > to debugging output.
33 around '_query_start' => sub {
34 my ($method, $self, $sql, @bind) = @_;
36 my $dsn = (try { $self->dsn }) || $self->_dbi_connect_info->[0];
38 my($op, $rest) = (($sql=~m/^(\w+)(.+)$/),'NOP', 'NO SQL');
39 my $storage_type = $self->can('active') ? 'REPLICANT' : 'MASTER';
42 if ((reftype($dsn)||'') ne 'CODE') {
43 "$op [DSN_$storage_type=$dsn]$rest";
45 elsif (my $id = try { $self->id }) {
46 "$op [$storage_type=$id]$rest";
49 "$op [$storage_type]$rest";
53 $self->$method($query, @bind);
58 L<DBIx::Class::Storage::DBI>
62 John Napiorkowski <john.napiorkowski@takkle.com>
66 You may distribute this code under the same terms as Perl itself.