1 package DBIx::Class::Storage::DBI::Replicated::WithDSN;
4 use Scalar::Util 'reftype';
5 requires qw/_query_start/;
7 use DBIx::Class::_Util 'dbic_internal_try';
9 use namespace::clean -except => 'meta';
13 DBIx::Class::Storage::DBI::Replicated::WithDSN - A DBI Storage Role with DSN
14 information in trace output
18 This class is used internally by L<DBIx::Class::Storage::DBI::Replicated>.
22 This role adds C<DSN: > info to storage debugging output.
26 This class defines the following methods.
28 =head2 around: _query_start
30 Add C<DSN: > to debugging output.
34 around '_query_start' => sub {
35 my ($method, $self, $sql, @bind) = @_;
37 my $dsn = (dbic_internal_try { $self->dsn }) || $self->_dbi_connect_info->[0];
39 my($op, $rest) = (($sql=~m/^(\w+)(.+)$/),'NOP', 'NO SQL');
40 my $storage_type = $self->can('active') ? 'REPLICANT' : 'MASTER';
43 if ((reftype($dsn)||'') ne 'CODE') {
44 "$op [DSN_$storage_type=$dsn]$rest";
46 elsif (my $id = dbic_internal_try { $self->id }) {
47 "$op [$storage_type=$id]$rest";
50 "$op [$storage_type]$rest";
54 $self->$method($query, @bind);
59 L<DBIx::Class::Storage::DBI>
61 =head1 FURTHER QUESTIONS?
63 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
65 =head1 COPYRIGHT AND LICENSE
67 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
68 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
69 redistribute it and/or modify it under the same terms as the
70 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.