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>
60 =head1 FURTHER QUESTIONS?
62 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
64 =head1 COPYRIGHT AND LICENSE
66 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
67 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
68 redistribute it and/or modify it under the same terms as the
69 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.