9 sub mc_diag { diag (@_) if $ENV{DBIC_MULTICREATE_DEBUG} };
11 my $schema = DBICTest->init_schema();
14 * Try a diamond multicreate
16 Artist -> has_many -> Artwork_to_Artist -> belongs_to
18 belongs_to <- CD <- belongs_to <- Artwork <-/
25 $schema->resultset ('Artist')->create ({
26 name => 'The wooled wolf',
27 artwork_to_artist => [{
30 title => 'Wool explosive',
32 artist => { name => 'The black exploding sheep' },
38 my $art2 = $schema->resultset ('Artist')->find ({ name => 'The black exploding sheep' });
39 ok ($art2, 'Second artist exists');
41 my $cd = $art2->cds->single;
42 is ($cd->title, 'Wool explosive', 'correctly created CD');
45 [ $cd->artwork->artists->get_column ('name')->all ],
46 [ 'The wooled wolf' ],
47 'Artist correctly attached to artwork',
50 }, 'Diamond chain creation ok');