From: Arthur Axel 'fREW' Schmidt <frioux@gmail.com>
Date: Tue, 9 Nov 2010 00:45:46 +0000 (-0600)
Subject: Leave quotes from DBIC in bindargs
X-Git-Tag: v1.70~4
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fb98df489bcd8f1d0edeb5258768f3d2ef6c5654;p=dbsrgits%2FSQL-Abstract.git

Leave quotes from DBIC in bindargs
---

diff --git a/Changes b/Changes
index ffdfcf0..5b96ba0 100644
--- 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
diff --git a/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm b/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm
index 023499e..a263001 100644
--- a/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm
+++ b/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm
@@ -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) {
diff --git a/lib/SQL/Abstract/Tree.pm b/lib/SQL/Abstract/Tree.pm
index a8894f2..0cceed8 100644
--- a/lib/SQL/Abstract/Tree.pm
+++ b/lib/SQL/Abstract/Tree.pm
@@ -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 '?'
 }
diff --git a/t/dbic/no-repeats.t b/t/dbic/no-repeats.t
index 56e4891..29842f0 100644
--- a/t/dbic/no-repeats.t
+++ b/t/dbic/no-repeats.t
@@ -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,
 });