Yeah, committing the new tests would help ...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / MightHave.pm
CommitLineData
b28cc0ba 1package DBIx::Class::CDBICompat::MightHave;
2
3use strict;
4use warnings;
5
6sub might_have {
7 my ($class, $rel, $f_class, @columns) = @_;
8 my ($pri, $too_many) = keys %{ $class->_primaries };
9 $class->throw( "might_have only works with a single primary key; ${class} has more" )
10 if $too_many;
11 my $f_pri;
12 ($f_pri, $too_many) = keys %{ $f_class->_primaries };
13 $class->throw( "might_have only works with a single primary key; ${f_class} has more" )
14 if $too_many;
15 $class->add_relationship($rel, $f_class,
16 { "foreign.${f_pri}" => "self.${pri}" },
17 { accessor => 'single', proxy => \@columns,
18 cascade_update => 1, cascade_delete => 1 });
19 1;
20}
21
221;