1 package DBIx::Class::Storage::Debug::PrettyPrint;
6 use base 'DBIx::Class::Storage::Statistics';
8 use SQL::Abstract::Tree;
10 __PACKAGE__->mk_group_accessors( simple => '_sqlat' );
15 my $sqlat = SQL::Abstract::Tree->new(shift @_);
16 my $self = $class->next::method(@_);
18 $self->_sqlat($sqlat);
28 my $use_placeholders = !!$self->_sqlat->fill_in_placeholders;
30 # DBIC pre-quotes bindargs
31 $bindargs = [map { s/^'//; s/'$//; } @{$bindargs}] if $use_placeholders;
33 my $formatted = $self->_sqlat->format($string, $bindargs) . "\n";
35 $formatted = "$formatted: " . join ', ', @{$bindargs}
36 unless $use_placeholders;
38 $self->next::method($formatted, @_);
42 my ($self, $string, @bind) = @_;
44 if(defined $self->callback) {
46 $self->callback->($1, "$string: ".join(', ', @bind)."\n");
50 $self->print($string, \@bind);
59 package MyApp::Schema;
61 use parent 'DBIx::Class::Schema';
63 use DBIx::Class::Storage::Debug::PrettyPrint;
65 __PACKAGE__->load_namespaces;
67 my $pp = DBIx::Class::Storage::Debug::PrettyPrint->new({
74 my $ret = $self->next::method(@_);
76 $self->storage->debugobj($pp);