[Bast-commits] r9707 - in SQL-Abstract/1.x/trunk/lib:
DBIx/Class/Storage/Debug SQL/Abstract
frew at dev.catalyst.perl.org
frew at dev.catalyst.perl.org
Thu Sep 9 03:16:54 GMT 2010
Author: frew
Date: 2010-09-09 04:16:54 +0100 (Thu, 09 Sep 2010)
New Revision: 9707
Modified:
SQL-Abstract/1.x/trunk/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm
SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
Log:
integrate placeholder population with DBIC
Modified: SQL-Abstract/1.x/trunk/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm
===================================================================
--- SQL-Abstract/1.x/trunk/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm 2010-09-09 02:51:23 UTC (rev 9706)
+++ SQL-Abstract/1.x/trunk/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm 2010-09-09 03:16:54 UTC (rev 9707)
@@ -1,5 +1,8 @@
package DBIx::Class::Storage::Debug::PrettyPrint;
+use strict;
+use warnings;
+
use base 'DBIx::Class::Storage::Statistics';
use SQL::Abstract::Tree;
@@ -20,12 +23,33 @@
sub print {
my $self = shift;
my $string = shift;
+ my $bindargs = shift;
- my $formatted = $self->_sqlat->format($string);
+ 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";
+
+ $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
Modified: SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
===================================================================
--- SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm 2010-09-09 02:51:23 UTC (rev 9706)
+++ SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm 2010-09-09 03:16:54 UTC (rev 9707)
@@ -103,6 +103,7 @@
my %profiles = (
console => {
+ fill_in_placeholders => 1,
indent_string => ' ',
indent_amount => 2,
newline => "\n",
@@ -110,6 +111,7 @@
indentmap => { %indents },
},
console_monochrome => {
+ fill_in_placeholders => 1,
indent_string => ' ',
indent_amount => 2,
newline => "\n",
@@ -117,6 +119,7 @@
indentmap => { %indents },
},
html => {
+ fill_in_placeholders => 1,
indent_string => ' ',
indent_amount => 2,
newline => "<br />\n",
More information about the Bast-commits
mailing list