use warnings;
use Test::More;
-BEGIN {
- eval "use DBD::SQLite";
- plan $@
- ? ( skip_all => 'needs DBD::SQLite for testing' )
- : ( tests => 12 );
-}
+plan tests => 12;
use lib qw(t/lib);
my $queries;
$schema->storage->debugcb( sub{ $queries++ } );
+my $sdebug = $schema->storage->debug;
-eval "use DBD::SQLite";
-plan skip_all => 'needs DBD::SQLite for testing' if $@;
plan tests => 23;
my $rs = $schema->resultset("Artist")->search(
is( $queries, 1, 'revisiting a row does not issue a query when cache => 1' );
-$schema->storage->debug(0);
+$schema->storage->debug($sdebug);
my @a = $schema->resultset("Artist")->search(
{ },
is($queries, 1, 'only one SQL statement executed');
-$schema->storage->debug(0);
+$schema->storage->debug($sdebug);
# make sure related_resultset is deleted after object is updated
$artist->set_column('name', 'New Name');
is($queries, 1, 'only one SQL statement executed');
-$schema->storage->debug(0);
+$schema->storage->debug($sdebug);
my @objs;
#$artist = $rs->find(1);
is( $queries, 1, 'only one select statement on find with has_many prefetch on resultset' );
-$schema->storage->debug(0);
+$schema->storage->debug($sdebug);
my $schema = DBICTest->init_schema();
my $queries;
-#$schema->storage->debugfh(IO::File->new('t/var/temp.trace', 'w'));
$schema->storage->debugcb( sub{ $queries++ } );
+my $sdebug = $schema->storage->debug;
-eval "use DBD::SQLite";
-plan skip_all => 'needs DBD::SQLite for testing' if $@;
plan tests => 2;
-
my $cd = $schema->resultset("CD")->find(1);
$cd->title('test');
is($queries, 1, 'liner_notes (might_have) not prefetched - do not load
liner_notes on update');
-$schema->storage->debug(0);
+$schema->storage->debug($sdebug);
my $cd2 = $schema->resultset("CD")->find(2, {prefetch => 'liner_notes'});
is($queries, 1, 'liner_notes (might_have) prefetched - do not load
liner_notes on update');
-$schema->storage->debug(0);
-
+$schema->storage->debug($sdebug);
plan 'no_plan';
my $schema = DBICTest->init_schema();
+my $sdebug = $schema->storage->debug;
my $cd_rs = $schema->resultset('CD')->search (
{ 'tracks.cd' => { '!=', undef } },
{
my $query_cnt = 0;
$schema->storage->debugcb ( sub { $query_cnt++ } );
+ $schema->storage->debug (1);
$track_rs->reset;
while (my $collapsed_track = $track_rs->next) {
is ($query_cnt, 0, 'No queries on prefetched titles');
$schema->storage->debugcb (undef);
+ $schema->storage->debug ($sdebug);
}
# Test sql by hand, as the sqlite db will simply paper over
my $query_cnt = 0;
$schema->storage->debugcb ( sub { $query_cnt++ } );
+ $schema->storage->debug (1);
is ($top_cd->get_column ('track_count'), 4, 'Track count fetched correctly');
is ($top_cd->tracks->count, 4, 'Count of prefetched tracks rs still correct');
is ($query_cnt, 0, 'No queries executed during prefetched data access');
$schema->storage->debugcb (undef);
+ $schema->storage->debug ($sdebug);
}
use Test::Exception;
use lib qw(t/lib);
use DBICTest;
-use Data::Dumper;
+use IO::File;
plan tests => 10;
my $schema = DBICTest->init_schema();
+my $sdebug = $schema->storage->debug;
-use IO::File;
# once the following TODO is complete, remove the 2 warning tests immediately
# after the TODO block
ok(! $o_mm_warn, 'no warning on attempt to prefetch several same level has_many\'s (1 -> M + M)');
is($queries, 1, 'prefetch one->(has_many,has_many) ran exactly 1 query');
+ $schema->storage->debugcb (undef);
+ $schema->storage->debug ($sdebug);
+
is($pr_tracks_count, $tracks_count, 'equal count of prefetched relations over several same level has_many\'s (1 -> M + M)');
for ($pr_tracks_rs, $tracks_rs) {
ok(! $m_o_mm_warn, 'no warning on attempt to prefetch several same level has_many\'s (M -> 1 -> M + M)');
is($queries, 1, 'prefetch one->(has_many,has_many) ran exactly 1 query');
+ $schema->storage->debugcb (undef);
+ $schema->storage->debug ($sdebug);
is($pr_tags_count, $tags_count, 'equal count of prefetched relations over several same level has_many\'s (M -> 1 -> M + M)');
use lib qw(t/lib);
use DBICTest;
use Data::Dumper;
+use IO::File;
my $schema = DBICTest->init_schema();
-
my $orig_debug = $schema->storage->debug;
-use IO::File;
-
-BEGIN {
- eval "use DBD::SQLite";
- plan $@
- ? ( skip_all => 'needs DBD::SQLite for testing' )
- : ( tests => 45 );
-}
+plan tests => 45;
my $queries = 0;
$schema->storage->debugcb(sub { $queries++; });
is($queries, 0, 'chained search_related after has_many->has_many prefetch ran no queries');
+$schema->storage->debug($orig_debug);
+$schema->storage->debugobj->callback(undef);
use DBICTest;
my $schema = DBICTest->init_schema();
+my $sdebug = $schema->storage->debug;
plan tests => 78;
is($queries, 0, 'No SELECT made for belongs_to if key IS NULL');
$big_flop_cd->genre_inefficient; #should trigger a select query
is($queries, 1, 'SELECT made for belongs_to if key IS NULL when undef_on_null_fk disabled');
- $schema->storage->debug(0);
+ $schema->storage->debug($sdebug);
$schema->storage->debugcb(undef);
}
use DBIC::SqlMakerTest;
my $schema = DBICTest->init_schema();
+my $sdebug = $schema->storage->debug;
-#plan tests => 4;
-plan 'no_plan';
+plan tests => 6;
my $artist = $schema->resultset ('Artist')->first;
});
$schema->storage->debugcb(undef);
+$schema->storage->debug ($sdebug);
is_same_sql (
$sql[0],
my $schema = DBICTest->init_schema();
-#plan tests => 4;
-plan 'no_plan';
+plan tests => 9;
my $artist = $schema->resultset ('Artist')->first;