X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fprefetch%2Ffalse_colvalues.t;fp=t%2Fprefetch%2Ffalse_colvalues.t;h=468a27a854d1d8e752bc1f224100dc0a77531a4c;hb=49eeb48de3d8ff685926b595fa0f3f5e680eaee2;hp=5213e73afca9c2f44694f2bb5a25104172fdf841;hpb=2cfc22ddff9cb35524031dfc9d429d294b5e3d6e;p=dbsrgits%2FDBIx-Class.git diff --git a/t/prefetch/false_colvalues.t b/t/prefetch/false_colvalues.t index 5213e73..468a27a 100644 --- a/t/prefetch/false_colvalues.t +++ b/t/prefetch/false_colvalues.t @@ -15,29 +15,20 @@ $schema->resultset('CD')->create({ }, }); -my $orig_debug = $schema->storage->debug; - -my $queries = 0; -$schema->storage->debugcb(sub { $queries++; }); -$schema->storage->debug(1); - -my $cd = $schema->resultset('CD')->search( {}, { prefetch => 'artist' })->next; - -cmp_deeply - { $cd->get_columns }, - { artist => 0, cdid => 0, genreid => 0, single_track => 0, title => '', year => 0 }, - 'Expected CD columns present', -; - -cmp_deeply - { $cd->artist->get_columns }, - { artistid => 0, charfield => 0, name => "", rank => 0 }, - 'Expected Artist columns present', -; - -is $queries, 1, 'Only one query fired - prefetch worked'; - -$schema->storage->debugcb(undef); -$schema->storage->debug($orig_debug); +$schema->is_executed_querycount( sub { + my $cd = $schema->resultset('CD')->search( {}, { prefetch => 'artist' })->next; + + cmp_deeply + { $cd->get_columns }, + { artist => 0, cdid => 0, genreid => 0, single_track => 0, title => '', year => 0 }, + 'Expected CD columns present', + ; + + cmp_deeply + { $cd->artist->get_columns }, + { artistid => 0, charfield => 0, name => "", rank => 0 }, + 'Expected Artist columns present', + ; +}, 1, 'Only one query fired - prefetch worked' ); done_testing;