Commit | Line | Data |
ee356d00 |
1 | package DBIx::Class::Storage::DBI::Replicated::WithDSN; |
2 | |
3 | use Moose::Role; |
4 | requires qw/_query_start/; |
5 | |
6 | use namespace::clean -except => 'meta'; |
7 | |
8 | =head1 NAME |
9 | |
10 | DBIx::Class::Storage::DBI::Replicated::WithDSN - A DBI Storage Role with DSN |
11 | information in trace output |
12 | |
13 | =head1 SYNOPSIS |
14 | |
15 | This class is used internally by L<DBIx::Class::Storage::DBI::Replicated>. |
d4daee7b |
16 | |
ee356d00 |
17 | =head1 DESCRIPTION |
18 | |
19 | This role adds C<DSN: > info to storage debugging output. |
20 | |
21 | =head1 METHODS |
22 | |
23 | This class defines the following methods. |
24 | |
25 | =head2 around: _query_start |
26 | |
27 | Add C<DSN: > to debugging output. |
28 | |
29 | =cut |
30 | |
31 | around '_query_start' => sub { |
32 | my ($method, $self, $sql, @bind) = @_; |
33 | my $dsn = $self->_dbi_connect_info->[0]; |
cda869a8 |
34 | my($op, $rest) = (($sql=~m/^(\w+)(.+)$/),'NOP', 'NO SQL'); |
1fa4a3e2 |
35 | my $storage_type = $self->can('active') ? 'REPLICANT' : 'MASTER'; |
36 | |
cda869a8 |
37 | $self->$method("$op [DSN_$storage_type=$dsn]$rest", @bind); |
ee356d00 |
38 | }; |
39 | |
40 | =head1 ALSO SEE |
41 | |
42 | L<DBIx::Class::Storage::DBI> |
43 | |
44 | =head1 AUTHOR |
45 | |
46 | John Napiorkowski <john.napiorkowski@takkle.com> |
47 | |
48 | =head1 LICENSE |
49 | |
50 | You may distribute this code under the same terms as Perl itself. |
51 | |
52 | =cut |
53 | |
54 | 1; |