1 package DBIx::Class::Storage::DBI::Replicated::WithDSN;
4 use Scalar::Util 'reftype';
5 requires qw/_query_start/;
7 use namespace::clean -except => 'meta';
11 DBIx::Class::Storage::DBI::Replicated::WithDSN - A DBI Storage Role with DSN
12 information in trace output
16 This class is used internally by L<DBIx::Class::Storage::DBI::Replicated>.
20 This role adds C<DSN: > info to storage debugging output.
24 This class defines the following methods.
26 =head2 around: _query_start
28 Add C<DSN: > to debugging output.
32 around '_query_start' => sub {
33 my ($method, $self, $sql, @bind) = @_;
35 my $dsn = eval { $self->dsn } || $self->_dbi_connect_info->[0];
37 my($op, $rest) = (($sql=~m/^(\w+)(.+)$/),'NOP', 'NO SQL');
38 my $storage_type = $self->can('active') ? 'REPLICANT' : 'MASTER';
41 if ((reftype($dsn)||'') ne 'CODE') {
42 "$op [DSN_$storage_type=$dsn]$rest";
44 elsif (my $id = eval { $self->id }) {
45 "$op [$storage_type=$id]$rest";
48 "$op [$storage_type]$rest";
52 $self->$method($query, @bind);
57 L<DBIx::Class::Storage::DBI>
61 John Napiorkowski <john.napiorkowski@takkle.com>
65 You may distribute this code under the same terms as Perl itself.