9 my $schema = DBICTest->init_schema();
12 $schema->storage->debugcb (sub { push @{$query_stats->{$_[0]}}, $_[1] });
13 $schema->storage->debug (1);
16 local $TODO = 'This is an optimization task, will wait... a while';
20 $schema->resultset('Artist')->create ({
21 name => 'poor artist',
34 is ( @{$query_stats->{INSERT} || []}, 3, 'number of inserts during creation of artist with 2 cds' );
35 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds' )
36 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
42 $schema->resultset('Artist')->create ({
43 name => 'poorer artist',
48 genre => { name => 'vague genre' },
53 genre => { name => 'vague genre' },
58 is ( @{$query_stats->{INSERT} || []}, 4, 'number of inserts during creation of artist with 2 cds, converging on the same genre' );
59 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds, converging on the same genre' )
60 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
65 my $genre = $schema->resultset('Genre')->first;
67 $schema->resultset('Artist')->create ({
68 name => 'poorest artist',
83 is ( @{$query_stats->{INSERT} || []}, 3, 'number of inserts during creation of artist with 2 cds, converging on the same existing genre' );
84 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds, converging on the same existing genre' )
85 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
91 $schema->resultset('Artist')->create ({
92 name => 'poorer than the poorest artist',
100 name => 'jolly producer',
107 name => 'poorer than the poorest artist',
119 is ( @{$query_stats->{INSERT} || []}, 6, 'number of inserts during creation of artist->cd->producer->cd->same_artist' );
120 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist->cd->producer->cd->same_artist' )
121 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
126 $schema->resultset ('Artist')->find(1)->create_related (cds => {
132 name => 'jolly producer',
139 name => 'poorer than the poorest artist',
149 is ( @{$query_stats->{INSERT} || []}, 4, 'number of inserts during creation of existing_artist->cd->existing_producer->cd->existing_artist2' );
150 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of existing_artist->cd->existing_producer->cd->existing_artist2' )
151 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
157 my $artist = $schema->resultset ('Artist')->first;
158 my $producer = $schema->resultset ('Producer')->first;
160 $schema->resultset ('CD')->create ({
166 producer => $producer,
171 is ( @{$query_stats->{INSERT} || []}, 2, 'number of inserts during creation of artist_object->cd->producer_object' );
172 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist_object->cd->producer_object' )
173 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};