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);
26 my $bindargs = shift || [];
28 return if defined $bindargs && defined $bindargs->[0] &&
29 $bindargs->[0] eq q('__BULK_INSERT__');
31 my $use_placeholders = !!$self->_sqlat->fill_in_placeholders;
33 # DBIC pre-quotes bindargs
34 $bindargs = [map { s/^'//; s/'$//; $_ } @{$bindargs}] if $use_placeholders;
36 my $formatted = $self->_sqlat->format($string, $bindargs) . "\n";
38 $formatted = "$formatted: " . join ', ', @{$bindargs}
39 unless $use_placeholders;
41 $self->next::method($formatted, @_);
45 my ($self, $string, @bind) = @_;
47 if(defined $self->callback) {
49 $self->callback->($1, "$string: ".join(', ', @bind)."\n");
53 $self->print($string, \@bind);
62 package MyApp::Schema;
64 use parent 'DBIx::Class::Schema';
66 use DBIx::Class::Storage::Debug::PrettyPrint;
68 __PACKAGE__->load_namespaces;
70 my $pp = DBIx::Class::Storage::Debug::PrettyPrint->new({
77 my $ret = $self->next::method(@_);
79 $self->storage->debugobj($pp);