From: Peter Rabbitson Date: Sun, 25 Apr 2010 16:31:37 +0000 (+0000) Subject: Fix copy X-Git-Tag: 0.03001~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1dfd20a478d120b18700428d45f03e19b445bee4;p=dbsrgits%2FDBIx-Class-Tree.git Fix copy --- diff --git a/Changes b/Changes index 6f5944a..704e754 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,9 @@ Revision history for DBIx::Class::Tree + - Fixed the parents (note the plural) relationship to + not have cascade_copy set by default + 0.03000 2009-08-18 - Removed EXPERIMENTAL flags, because after 2 years there'd be bugs if there were any serious problems. (Ian Wells) diff --git a/lib/DBIx/Class/Tree/AdjacencyList.pm b/lib/DBIx/Class/Tree/AdjacencyList.pm index 025ebfb..285d5de 100644 --- a/lib/DBIx/Class/Tree/AdjacencyList.pm +++ b/lib/DBIx/Class/Tree/AdjacencyList.pm @@ -85,7 +85,7 @@ sub parent_column { my $primary_col = ($class->primary_columns())[0]; $class->belongs_to( '_parent' => $class => { "foreign.$primary_col" => "self.$parent_col" } ); $class->has_many( 'children' => $class => { "foreign.$parent_col" => "self.$primary_col" } ); - $class->has_many( 'parents' => $class => { "foreign.$primary_col" => "self.$parent_col" }, { cascade_delete => 0 } ); + $class->has_many( 'parents' => $class => { "foreign.$primary_col" => "self.$parent_col" }, { cascade_delete => 0, cascade_copy => 0 } ); $class->_parent_column( $parent_col ); return 1; } diff --git a/t/lib/TreeTest.pm b/t/lib/TreeTest.pm index d7228ff..0e66aa6 100644 --- a/t/lib/TreeTest.pm +++ b/t/lib/TreeTest.pm @@ -29,11 +29,6 @@ sub run_tests { $node->parent( $parent_id ); } - lives_and ( sub { - warn "BEGIN!!!!!\n\n"; - is( $nodes->find(3)->copy({name => 'special'})->name,'special','copy test'); - }, 'copy does not throw'); - ok( ($nodes->count()==81), 'correct number of nodes in random tree' ); ok( ($nodes->find(3)->children->count()==7), 'node 3 has correct number of children' ); ok( ($nodes->find(22)->children->count()==3), 'node 22 has correct number of children' ); @@ -59,6 +54,10 @@ sub run_tests { if( TreeTest::Schema::Node->can('position_column') ){ ok( check_positions(scalar $root->children()), 'positions are correct' ); } + + lives_and ( sub { + is( $nodes->find(3)->copy({name => 'special'})->name,'special','copy test'); + }, 'copy does not throw'); } sub check_positions {