Leave quotes from DBIC in bindargs
Arthur Axel 'fREW' Schmidt [Tue, 9 Nov 2010 00:45:46 +0000 (18:45 -0600)]
Changes
lib/DBIx/Class/Storage/Debug/PrettyPrint.pm
lib/SQL/Abstract/Tree.pm
t/dbic/no-repeats.t

diff --git a/Changes b/Changes
index ffdfcf0..5b96ba0 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
 Revision history for SQL::Abstract
 
+    - Leave quotes from DBIC in bindargs
     - Add error checking on "profile" for SQLA::Tree
     - Hide bulk inserts from DBIx::Class
     - Highlight transaction keywords
index 023499e..a263001 100644 (file)
@@ -55,9 +55,6 @@ sub print {
 
   my $use_placeholders = !!$self->_sqlat->fill_in_placeholders;
 
-  # DBIC pre-quotes bindargs
-  $bindargs = [map { s/^'//; s/'$//; $_ } @{$bindargs}] if $use_placeholders;
-
   my $sqlat = $self->_sqlat;
   my $formatted;
   if ($self->squash_repeats && $self->_last_sql eq $string) {
index a8894f2..0cceed8 100644 (file)
@@ -188,7 +188,7 @@ my %profiles = (
           my $magenta = [$c->('magenta'), $c->('reset')];
           my $b_o_w   = [$c->('black on_white'), $c->('reset')];
           (
-            placeholder_surround => [q(') . $c->('black on_magenta'), $c->('reset') . q(')],
+            placeholder_surround => [$c->('black on_magenta'), $c->('reset')],
             colormap => {
               'begin work'            => $b_o_w,
               commit                  => $b_o_w,
@@ -448,10 +448,12 @@ sub fill_in_placeholder {
 
    if ($self->fill_in_placeholders) {
       my $val = shift @{$bindargs} || '';
+      $val =~ s/^(')(.*)(')$/$2/;
+      my ($lquo, $rquo) = ($1 || '', $3 || '');
       my ($left, $right) = @{$self->placeholder_surround};
       $val =~ s/\\/\\\\/g;
       $val =~ s/'/\\'/g;
-      return qq($left$val$right)
+      return qq($left$lquo$val$rquo$right)
    }
    return '?'
 }
index 56e4891..29842f0 100644 (file)
@@ -11,7 +11,7 @@ my $pp = DBIx::Class::Storage::Debug::PrettyPrint->new({
    profile => 'none',
    squash_repeats => 1,
    fill_in_placeholders => 1,
-   placeholder_surround => [qw(' ')],
+   placeholder_surround => ['', ''],
    show_progress => 0,
 });