From: Jess Robinson Date: Sat, 10 Dec 2005 14:14:11 +0000 (+0000) Subject: Check for primary key existance X-Git-Tag: v0.05005~151 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1240ad98aef51c2b33675451b5dc7a7973fe26d6;p=dbsrgits%2FDBIx-Class.git Check for primary key existance --- diff --git a/lib/DBIx/Class/Relationship/BelongsTo.pm b/lib/DBIx/Class/Relationship/BelongsTo.pm index 7435d7b..f59f532 100644 --- a/lib/DBIx/Class/Relationship/BelongsTo.pm +++ b/lib/DBIx/Class/Relationship/BelongsTo.pm @@ -18,6 +18,7 @@ sub belongs_to { $class->throw("Can't infer join condition for ${rel} on ${class}; unable to load ${f_class}") unless $f_loaded; my ($pri, $too_many) = keys %f_primaries; $class->throw("Can't infer join condition for ${rel} on ${class}; ${f_class} has multiple primary key") if $too_many; + $class->throw("Can't find any primary keys for $f_class, try adding some") if !$pri; my $acc_type = ($class->has_column($rel)) ? 'filter' : 'single'; $class->add_relationship($rel, $f_class, { "foreign.${pri}" => "self.${rel}" },