1 use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
9 use lib 't/cdbi/testlib';
14 Director->has_many(nasties => 'Film');
16 my $dir = Director->insert({
17 name => "Lewis Teague",
19 my $kk = $dir->add_to_nasties({
22 is $kk->director, $dir, "Director set OK";
23 is $dir->nasties, 1, "We have one nasty";
26 ok !Film->retrieve("Alligator"), "has_many cascade deletes by default";
30 # Two ways of saying not to cascade
31 for my $args ({ no_cascade_delete => 1 }, { cascade => "None" }) {
32 Director->has_many(nasties => 'Film', $args);
34 my $dir = Director->insert({
35 name => "Lewis Teague",
37 my $kk = $dir->add_to_nasties({
40 is $kk->director, $dir, "Director set OK";
41 is $dir->nasties, 1, "We have one nasty";
44 local $Data::Dumper::Terse = 1;
45 ok +Film->retrieve("Alligator"), 'has_many with ' . Dumper ($args);;
51 # local $TODO = 'cascade => "Fail" unimplemented';
53 # Director->has_many(nasties => Film => { cascade => 'Fail' });
55 # my $dir = Director->insert({ name => "Nasty Noddy" });
56 # my $kk = $dir->add_to_nasties({ Title => 'Killer Killers' });
57 # is $kk->director, $dir, "Director set OK";
58 # is $dir->nasties, 1, "We have one nasty";
60 # ok !eval { $dir->delete };
61 # like $@, qr/1/, "Can't delete while films exist";
63 # my $rr = $dir->add_to_nasties({ Title => 'Revenge of the Revengers' });
64 # ok !eval { $dir->delete };
65 # like $@, qr/2/, "Still can't delete";
67 # $dir->nasties->delete_all;
68 # ok eval { $dir->delete };
69 # is $@, '', "Can delete once films are gone";