package DBIx::Class::Storage::Debug::PrettyPrint;
+use strict;
+use warnings;
+
use base 'DBIx::Class::Storage::Statistics';
use SQL::Abstract::Tree;
sub print {
my $self = shift;
my $string = shift;
+ my $bindargs = shift;
+
+ my $use_placeholders = !!$self->_sqlat->fill_in_placeholders;
+
+ # DBIC pre-quotes bindargs
+ $bindargs = [map { s/^'//; s/'$//; } @{$bindargs}] if $use_placeholders;
+
+ my $formatted = $self->_sqlat->format($string, $bindargs) . "\n";
- my $formatted = $self->_sqlat->format($string);
+ $formatted = "$formatted: " . join ', ', @{$bindargs}
+ unless $use_placeholders;
$self->next::method($formatted, @_);
}
+sub query_start {
+ my ($self, $string, @bind) = @_;
+
+ if(defined $self->callback) {
+ $string =~ m/^(\w+)/;
+ $self->callback->($1, "$string: ".join(', ', @bind)."\n");
+ return;
+ }
+
+ $self->print($string, \@bind);
+}
+
1;
=pod
my %profiles = (
console => {
+ fill_in_placeholders => 1,
indent_string => ' ',
indent_amount => 2,
newline => "\n",
indentmap => { %indents },
},
console_monochrome => {
+ fill_in_placeholders => 1,
indent_string => ' ',
indent_amount => 2,
newline => "\n",
indentmap => { %indents },
},
html => {
+ fill_in_placeholders => 1,
indent_string => ' ',
indent_amount => 2,
newline => "<br />\n",