From: Tim Bunce Date: Tue, 10 Jan 2012 12:57:05 +0000 (-0500) Subject: warn when redefining relationships (RT#73876) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=167e0a188a804834caa203b974168835e688858e;p=dbsrgits%2FDBIx-Class-Historic.git warn when redefining relationships (RT#73876) Add a carp when a relationship is being redefined and DBIC_TRACE is on. --- diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 443e81e..ac48ee2 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -490,7 +490,9 @@ talexb: Alex Beamish tamias: Ronald J Kimball -teejay : Aaron Trevena +teejay: Aaron Trevena + +timbunce: Tim Bunce Todd Lipcon diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 8bf7d67..c030d94 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -1248,6 +1248,12 @@ sub add_relationship { } my %rels = %{ $self->_relationships }; + if ($rels{$rel} && $ENV{DBIC_TRACE}) { + # warning is useful e.g. for large Schema::Loader generated schemas where + # relationships have been added manually and then later generated by + # Schema::Loader. + carp "$rel relationship redefined"; + } $rels{$rel} = { class => $f_source_name, source => $f_source_name, cond => $cond,