1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
8 plan skip_all => 'Disable test entirely until multicreate is rewritten in terms of subqueries';
15 my $schema = DBICTest->init_schema();
18 $schema->storage->debugcb (sub { push @{$query_stats->{$_[0]}}, $_[1] });
19 $schema->storage->debug (1);
23 $schema->resultset('Artist')->create ({
24 name => 'poor artist',
37 is ( @{$query_stats->{INSERT} || []}, 3, 'number of inserts during creation of artist with 2 cds' );
38 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds' )
39 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
45 $schema->resultset('Artist')->create ({
46 name => 'poorer artist',
51 genre => { name => 'vague genre' },
56 genre => { name => 'vague genre' },
61 is ( @{$query_stats->{INSERT} || []}, 4, 'number of inserts during creation of artist with 2 cds, converging on the same genre' );
62 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds, converging on the same genre' )
63 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
68 my $genre = $schema->resultset('Genre')->first;
70 $schema->resultset('Artist')->create ({
71 name => 'poorest artist',
86 is ( @{$query_stats->{INSERT} || []}, 3, 'number of inserts during creation of artist with 2 cds, converging on the same existing genre' );
87 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist with 2 cds, converging on the same existing genre' )
88 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
94 $schema->resultset('Artist')->create ({
95 name => 'poorer than the poorest artist',
103 name => 'jolly producer',
110 name => 'poorer than the poorest artist',
122 is ( @{$query_stats->{INSERT} || []}, 6, 'number of inserts during creation of artist->cd->producer->cd->same_artist' );
123 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist->cd->producer->cd->same_artist' )
124 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
129 $schema->resultset ('Artist')->find(1)->create_related (cds => {
135 name => 'jolly producer',
142 name => 'poorer than the poorest artist',
152 is ( @{$query_stats->{INSERT} || []}, 4, 'number of inserts during creation of existing_artist->cd->existing_producer->cd->existing_artist2' );
153 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of existing_artist->cd->existing_producer->cd->existing_artist2' )
154 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};
160 my $artist = $schema->resultset ('Artist')->first;
161 my $producer = $schema->resultset ('Producer')->first;
163 $schema->resultset ('CD')->create ({
169 producer => $producer,
174 is ( @{$query_stats->{INSERT} || []}, 2, 'number of inserts during creation of artist_object->cd->producer_object' );
175 is ( @{$query_stats->{SELECT} || []}, 0, 'number of selects during creation of artist_object->cd->producer_object' )
176 || $ENV{DBIC_MULTICREATE_DEBUG} && diag join "\n", @{$query_stats->{SELECT} || []};