6 plan skip_all => 'Disable test entirely until multicreate is rewritten in terms of subqueries';
13 my $schema = DBICTest->init_schema();
16 $schema->storage->debugcb (sub { push @{$query_stats->{$_[0]}}, $_[1] });
17 $schema->storage->debug (1);
21 $schema->resultset('Artist')->create ({
22 name => 'poor artist',
35 is ( @{$query_stats->{INSERT} || []}, 3, 'number of inserts during creation of artist with 2 cds' );
36 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds' )
37 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
43 $schema->resultset('Artist')->create ({
44 name => 'poorer artist',
49 genre => { name => 'vague genre' },
54 genre => { name => 'vague genre' },
59 is ( @{$query_stats->{INSERT} || []}, 4, 'number of inserts during creation of artist with 2 cds, converging on the same genre' );
60 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds, converging on the same genre' )
61 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
66 my $genre = $schema->resultset('Genre')->first;
68 $schema->resultset('Artist')->create ({
69 name => 'poorest artist',
84 is ( @{$query_stats->{INSERT} || []}, 3, 'number of inserts during creation of artist with 2 cds, converging on the same existing genre' );
85 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds, converging on the same existing genre' )
86 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
92 $schema->resultset('Artist')->create ({
93 name => 'poorer than the poorest artist',
101 name => 'jolly producer',
108 name => 'poorer than the poorest artist',
120 is ( @{$query_stats->{INSERT} || []}, 6, 'number of inserts during creation of artist->cd->producer->cd->same_artist' );
121 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist->cd->producer->cd->same_artist' )
122 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
127 $schema->resultset ('Artist')->find(1)->create_related (cds => {
133 name => 'jolly producer',
140 name => 'poorer than the poorest artist',
150 is ( @{$query_stats->{INSERT} || []}, 4, 'number of inserts during creation of existing_artist->cd->existing_producer->cd->existing_artist2' );
151 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of existing_artist->cd->existing_producer->cd->existing_artist2' )
152 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
158 my $artist = $schema->resultset ('Artist')->first;
159 my $producer = $schema->resultset ('Producer')->first;
161 $schema->resultset ('CD')->create ({
167 producer => $producer,
172 is ( @{$query_stats->{INSERT} || []}, 2, 'number of inserts during creation of artist_object->cd->producer_object' );
173 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist_object->cd->producer_object' )
174 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};