add some docs
[dbsrgits/SQL-Abstract.git] / lib / DBIx / Class / Storage / PrettyPrinter.pm
CommitLineData
1dc93d17 1package DBIx::Class::Storage::PrettyPrinter;
2
3use base 'DBIx::Class::Storage::Statistics';
4
5use SQL::Abstract::Tree;
6
7__PACKAGE__->mk_group_accessors( simple => '_sqlat' );
8
9sub new {
10 my $class = shift;
11
12 my $sqlat = SQL::Abstract::Tree->new(shift @_);
13 my $self = $class->next::method(@_);
14
15 $self->_sqlat($sqlat);
16
17 return $self
18}
19
20sub query_start {
21 my $self = shift;
22 my $string = shift;
23
24 my $formatted = $self->_sqlat->format($string);
25
26 $self->next::method($formatted, @_);
27}
28
291;
6b1bf9f8 30
31=pod
32
33=head1 SYNOPSIS
34
35 package MyApp::Schema;
36
37 use parent 'DBIx::Class::Schema';
38
39 use DBIx::Class::Storage::PrettyPrinter;
40
41 __PACKAGE__->load_namespaces;
42
43 my $pp = DBIx::Class::Storage::PrettyPrinter->new({ profile => 'console' });
44
45 sub connection {
46 my $self = shift;
47
48 my $ret = $self->next::method(@_);
49
50 $self->storage->debugobj($pp);
51
52 $ret
53 }
54