From: Rafael Kitover Date: Wed, 5 May 2010 15:49:32 +0000 (-0400) Subject: remove is_deferrable => 1 from default for belongs_to rels X-Git-Tag: 0.07000~36 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6818ce9fd83510b82b5d1cc152a230954b332e35;p=dbsrgits%2FDBIx-Class-Schema-Loader.git remove is_deferrable => 1 from default for belongs_to rels --- diff --git a/Changes b/Changes index 1d28380..2404d9a 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - remove is_deferrable => 1 from default for belongs_to rels - better type info for Oracle - preliminary Informix support - unregister dropped sources on rescan diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 61c8f4f..8969b66 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -255,12 +255,10 @@ relationship types override those set in 'all'. For example: relationship_attrs => { - all => { cascade_delete => 0 }, - has_many => { cascade_delete => 1 }, + belongs_to => { is_deferrable => 1 }, }, -will set the C option to 0 for all generated relationships, -except for C, which will have cascade_delete as 1. +use this to make your foreign key constraints DEFERRABLE. =head2 debug diff --git a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm index 63a284c..7611f75 100644 --- a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm +++ b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm @@ -163,7 +163,7 @@ sub _default_relationship_attrs { +{ belongs_to => { on_delete => 'CASCADE', on_update => 'CASCADE', - is_deferrable => 1, +# is_deferrable => 1, }, } } diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 1088690..5ed2434 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -605,8 +605,8 @@ sub test_schema { is $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{on_update}, 'CASCADE', "on_update => 'CASCADE' on belongs_to by default"; - is $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{is_deferrable}, 1, - "is_deferrable => 1 on belongs_to by default"; + ok ((not exists $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{is_deferrable}), + "is_deferrable => 1 not on belongs_to by default"); ok ((not exists $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{cascade_delete}), 'belongs_to does not have cascade_delete');