11 my $schema = DBICTest->init_schema();
14 $schema->storage->debugcb (sub { push @{$query_stats->{$_[0]}}, $_[1] });
15 $schema->storage->debug (1);
18 local $TODO = 'This is an optimization task, will wait... a while';
22 $schema->resultset('Artist')->create ({
23 name => 'poor artist',
36 is ( @{$query_stats->{INSERT} || []}, 3, 'number of inserts during creation of artist with 2 cds' );
37 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds' )
38 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
44 $schema->resultset('Artist')->create ({
45 name => 'poorer artist',
50 genre => { name => 'vague genre' },
55 genre => { name => 'vague genre' },
60 is ( @{$query_stats->{INSERT} || []}, 4, 'number of inserts during creation of artist with 2 cds, converging on the same genre' );
61 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds, converging on the same genre' )
62 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
67 my $genre = $schema->resultset('Genre')->first;
69 $schema->resultset('Artist')->create ({
70 name => 'poorest artist',
85 is ( @{$query_stats->{INSERT} || []}, 3, 'number of inserts during creation of artist with 2 cds, converging on the same existing genre' );
86 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds, converging on the same existing genre' )
87 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
93 $schema->resultset('Artist')->create ({
94 name => 'poorer than the poorest artist',
102 name => 'jolly producer',
109 name => 'poorer than the poorest artist',
121 is ( @{$query_stats->{INSERT} || []}, 6, 'number of inserts during creation of artist->cd->producer->cd->same_artist' );
122 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist->cd->producer->cd->same_artist' )
123 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
128 $schema->resultset ('Artist')->find(1)->create_related (cds => {
134 name => 'jolly producer',
141 name => 'poorer than the poorest artist',
151 is ( @{$query_stats->{INSERT} || []}, 4, 'number of inserts during creation of existing_artist->cd->existing_producer->cd->existing_artist2' );
152 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of existing_artist->cd->existing_producer->cd->existing_artist2' )
153 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
159 my $artist = $schema->resultset ('Artist')->first;
160 my $producer = $schema->resultset ('Producer')->first;
162 $schema->resultset ('CD')->create ({
168 producer => $producer,
173 is ( @{$query_stats->{INSERT} || []}, 2, 'number of inserts during creation of artist_object->cd->producer_object' );
174 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist_object->cd->producer_object' )
175 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};