From: Arthur Axel 'fREW' Schmidt Date: Sun, 24 Oct 2010 21:06:44 +0000 (-0500) Subject: tests for bulk insert X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fda8a675d11f0acce2ec53f155e8e3ca70b7db7c;p=scpubgit%2FQ-Branch.git tests for bulk insert --- diff --git a/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm b/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm index 8a8c659..65e95bd 100644 --- a/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm +++ b/lib/DBIx/Class/Storage/Debug/PrettyPrint.pm @@ -60,11 +60,11 @@ sub print { my $formatted; if ($self->squash_repeats && $self->_last_sql eq $string) { my ( $l, $r ) = @{ $sqlat->placeholder_surround }; - $formatted = '... : ' . join(', ', map "$l$_$r", @$bindargs) . "\n"; + $formatted = '... : ' . join(', ', map "$l$_$r", @$bindargs) } else { $self->_last_sql($string); - $formatted = $sqlat->format($string, $bindargs) . "\n"; - $formatted = "$formatted: " . join ', ', @{$bindargs} + $formatted = $sqlat->format($string, $bindargs); + $formatted = "$formatted : " . join ', ', @{$bindargs} unless $use_placeholders; } diff --git a/t/dbic/bulk-insert.t b/t/dbic/bulk-insert.t new file mode 100644 index 0000000..47f4660 --- /dev/null +++ b/t/dbic/bulk-insert.t @@ -0,0 +1,26 @@ +use strict; +use warnings; + +use Test::More; +use DBIx::Class::Storage::Debug::PrettyPrint; + +my $cap; +open my $fh, '>', \$cap; + +my $pp = DBIx::Class::Storage::Debug::PrettyPrint->new({ + profile => 'none', + fill_in_placeholders => 1, + placeholder_surround => [qw(' ')], + show_progress => 0, +}); + +$pp->debugfh($fh); + +$pp->query_start('INSERT INTO self_ref_alias (alias, self_ref) VALUES ( ?, ? )', qw('__BULK_INSERT__' '1')); +is( + $cap, + qq{INSERT INTO self_ref_alias (alias, self_ref) VALUES (?, ?) : '__BULK_INSERT__', '1'\n}, + 'SQL Logged' +); + +done_testing;