X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F19quotes.t;h=75b4668262f25947376015084ff0ae066a3349b2;hb=5597834e4341123c5d6782ec8c0f66b4e7934e1d;hp=19d4031f1cbcb4b31dc66bef0b7e42b78a774aef;hpb=949172b0fa30a832d268c3f55f97247a10742314;p=dbsrgits%2FDBIx-Class.git diff --git a/t/19quotes.t b/t/19quotes.t index 19d4031..75b4668 100644 --- a/t/19quotes.t +++ b/t/19quotes.t @@ -3,6 +3,8 @@ use warnings; use Test::More; use IO::File; + +use lib qw(t/lib); use DBIC::SqlMakerTest; BEGIN { @@ -12,19 +14,18 @@ BEGIN { : ( tests => 7 ); } -use lib qw(t/lib); use_ok('DBICTest'); -use_ok('DBICTest::DBICDebugObj'); +use_ok('DBIC::DebugObj'); my $schema = DBICTest->init_schema(); -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, @bind) = (''); -$schema->storage->debugobj(DBICTest::DBICDebugObj->new(\$sql, \@bind)); +$schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)); $schema->storage->debug(1); my $rs; @@ -34,9 +35,12 @@ $rs = $schema->resultset('CD')->search( { join => 'artist' }); eval { $rs->count }; 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' + $sql, + \@bind, + "SELECT COUNT( * ) FROM (SELECT `me`.`cdid` FROM `cd` `me` JOIN `artist` `artist` ON `artist`.`artistid` = `me`.`artist` WHERE ( ( `artist`.`name` = ? AND `me`.`year` = ? ) ) GROUP BY `me`.`cdid`) `count_subq`", + ["'Caterwauler McCrae'", "'2001'"], + + 'got correct SQL for joined count query with quoting' ); my $order = 'year DESC'; @@ -58,8 +62,10 @@ $rs = $schema->resultset('CD')->search( { join => 'artist' }); eval { $rs->count }; 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'"], + $sql, + \@bind, + "SELECT COUNT( * ) FROM (SELECT [me].[cdid] FROM [cd] [me] JOIN [artist] [artist] ON [artist].[artistid] = [me].[artist] WHERE ( ( [artist].[name] = ? AND [me].[year] = ? ) ) GROUP BY [me].[cdid]) [count_subq]", + ["'Caterwauler McCrae'", "'2001'"], 'got correct SQL for count query with bracket quoting' );