X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F19quotes.t;h=622eefb83ea65add3e92dac2b56e588ca974c9b2;hb=d4483998dff1af8eff35b3c5398f564a9a1fb9d8;hp=646131b07558f34c5c1459676f302cdec4081644;hpb=c216324aa4b0f79ba056fbe74adbd735421e378a;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/19quotes.t b/t/19quotes.t index 646131b..622eefb 100644 --- a/t/19quotes.t +++ b/t/19quotes.t @@ -4,29 +4,28 @@ use warnings; use Test::More; use IO::File; +use lib qw(t/lib); +use DBIC::SqlMakerTest; + BEGIN { eval "use DBD::SQLite"; plan $@ ? ( skip_all => 'needs DBD::SQLite for testing' ) - : ( tests => 6 ); + : ( tests => 7 ); } -use lib qw(t/lib); use_ok('DBICTest'); +use_ok('DBIC::DebugObj'); my $schema = DBICTest->init_schema(); -my $orig_debugcb = $schema->storage->debugcb; -my $orig_debug = $schema->storage->debug; - -diag('Testing against ' . join(' ', map { $schema->storage->dbh->get_info($_) } qw/17 18/)); +#diag('Testing against ' . join(' ', map { $schema->storage->dbh->get_info($_) } qw/17 18/)); $schema->storage->sql_maker->quote_char('`'); $schema->storage->sql_maker->name_sep('.'); -my $sql = ''; - -$schema->storage->debugcb(sub { $sql = $_[1] }); +my ($sql, @bind) = (''); +$schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)); $schema->storage->debug(1); my $rs; @@ -35,7 +34,11 @@ $rs = $schema->resultset('CD')->search( { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' }, { join => 'artist' }); eval { $rs->count }; -like($sql, qr/\QSELECT COUNT( * ) FROM `cd` `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )\E/, 'got correct SQL for count query with quoting'); +is_same_sql_bind( + $sql, \@bind, + "SELECT COUNT( * ) FROM `cd` `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"], + 'got correct SQL for count query with quoting' +); my $order = 'year DESC'; $rs = $schema->resultset('CD')->search({}, @@ -55,7 +58,11 @@ $rs = $schema->resultset('CD')->search( { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' }, { join => 'artist' }); eval { $rs->count }; -like($sql, qr/\QSELECT COUNT( * ) FROM [cd] [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )\E/, 'got correct SQL for count query with bracket quoting'); +is_same_sql_bind( + $sql, \@bind, + "SELECT COUNT( * ) FROM [cd] [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )", ["'Caterwauler McCrae'", "'2001'"], + 'got correct SQL for count query with bracket quoting' +); my %data = ( name => 'Bill', @@ -66,6 +73,3 @@ $schema->storage->sql_maker->quote_char('`'); $schema->storage->sql_maker->name_sep('.'); is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE'); - -$schema->storage->debugcb($orig_debugcb); -$schema->storage->debug($orig_debug);