From: Rafael Kitover Date: Tue, 24 May 2011 15:15:28 +0000 (-0400) Subject: set cascade_update => 0 on might_have relationships X-Git-Tag: 0.07011~108 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9b1dd93554ec8f70923940e2ae88e2e0260d0b55;p=dbsrgits%2FDBIx-Class-Schema-Loader.git set cascade_update => 0 on might_have relationships --- diff --git a/Changes b/Changes index 06a78b7..f8ead40 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - set cascade_update => 0 on might_have relationships - generate POD for result_base_class, additional_classes, additional_base_classes, left_base_classes, components, result_components_map, result_roles and result_roles_map diff --git a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm index 14307e9..96318b4 100644 --- a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm +++ b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm @@ -192,6 +192,7 @@ sub _default_relationship_attrs { +{ might_have => { cascade_delete => 0, cascade_copy => 0, + cascade_update => 0, }, belongs_to => { on_delete => 'CASCADE', diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index bc7cd8a..20dbb0b 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -102,7 +102,7 @@ sub run_tests { $num_rescans++ if $self->{vendor} eq 'Firebird'; plan tests => @connect_info * - (199 + $num_rescans * $col_accessor_map_tests + $extra_count + ($self->{data_type_tests}{test_count} || 0)); + (202 + $num_rescans * $col_accessor_map_tests + $extra_count + ($self->{data_type_tests}{test_count} || 0)); foreach my $info_idx (0..$#connect_info) { my $info = $connect_info[$info_idx]; @@ -556,7 +556,7 @@ sub test_schema { } SKIP: { - skip $self->{skip_rels}, 120 if $self->{skip_rels}; + skip $self->{skip_rels}, 123 if $self->{skip_rels}; my $moniker3 = $monikers->{loader_test3}; my $class3 = $classes->{loader_test3}; @@ -715,6 +715,9 @@ sub test_schema { is try { $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{cascade_copy} }, 0, 'cascade_copy => 0 on has_many by default'; + ok ((not try { exists $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{cascade_update} }), + 'has_many does not have cascade_update'); + ok ((not try { exists $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{on_delete} }), 'has_many does not have on_delete'); @@ -739,12 +742,18 @@ sub test_schema { ok ((not try { exists $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{cascade_copy} }), 'belongs_to does not have cascade_copy'); + ok ((not try { exists $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{cascade_update} }), + 'belongs_to does not have cascade_update'); + is try { $rsobj27->result_source->relationship_info('loader_test28')->{attrs}{cascade_delete} }, 0, 'cascade_delete => 0 on might_have by default'; is try { $rsobj27->result_source->relationship_info('loader_test28')->{attrs}{cascade_copy} }, 0, 'cascade_copy => 0 on might_have by default'; + is try { $rsobj27->result_source->relationship_info('loader_test28')->{attrs}{cascade_update} }, 0, + 'cascade_update => 0 on might_have by default'; + ok ((not try { exists $rsobj27->result_source->relationship_info('loader_test28')->{attrs}{on_delete} }), 'might_have does not have on_delete');