X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FCDBICompat%2FMightHave.pm;h=519c6fe1f9d39a6bbfade53fbf46542de784c389;hb=30813c9065defa8d2345b00fa368448f9067a633;hp=5cf073e04362c36f07b074d9de70169637c81290;hpb=b28cc0ba2d1d443728c9cb48d97e5a2cdccf8cb4;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/CDBICompat/MightHave.pm b/lib/DBIx/Class/CDBICompat/MightHave.pm index 5cf073e..519c6fe 100644 --- a/lib/DBIx/Class/CDBICompat/MightHave.pm +++ b/lib/DBIx/Class/CDBICompat/MightHave.pm @@ -1,22 +1,17 @@ -package DBIx::Class::CDBICompat::MightHave; +package # hide from PAUSE + DBIx::Class::CDBICompat::MightHave; use strict; use warnings; sub might_have { my ($class, $rel, $f_class, @columns) = @_; - my ($pri, $too_many) = keys %{ $class->_primaries }; - $class->throw( "might_have only works with a single primary key; ${class} has more" ) - if $too_many; - my $f_pri; - ($f_pri, $too_many) = keys %{ $f_class->_primaries }; - $class->throw( "might_have only works with a single primary key; ${f_class} has more" ) - if $too_many; - $class->add_relationship($rel, $f_class, - { "foreign.${f_pri}" => "self.${pri}" }, - { accessor => 'single', proxy => \@columns, - cascade_update => 1, cascade_delete => 1 }); - 1; + if (ref $columns[0] || !defined $columns[0]) { + return $class->next::method($rel, $f_class, @columns); + } else { + return $class->next::method($rel, $f_class, undef, + { proxy => \@columns }); + } } 1;