described schema better, and added note about when you want to use it
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / CDBICompat / HasA.pm
index c4595c6..e35c221 100644 (file)
@@ -7,7 +7,7 @@ sub has_a {
   my ($self, $col, $f_class, %args) = @_;
   $self->throw( "No such column ${col}" ) unless $self->_columns->{$col};
   eval "require $f_class";
-  if ($args{'inflate'} || $args{'deflate'}) {
+  if ($args{'inflate'} || $args{'deflate'}) { # Non-database has_a
     if (!ref $args{'inflate'}) {
       my $meth = $args{'inflate'};
       $args{'inflate'} = sub { $f_class->$meth(shift); };
@@ -19,12 +19,8 @@ sub has_a {
     $self->inflate_column($col, \%args);
     return 1;
   }
-  my ($pri, $too_many) = keys %{ $f_class->_primaries };
-  $self->throw( "has_a only works with a single primary key; ${f_class} has more" )
-    if $too_many;
-  $self->add_relationship($col, $f_class,
-                            { "foreign.${pri}" => "self.${col}" },
-                            { accessor => 'filter' } );
+
+  $self->belongs_to($col, $f_class);
   return 1;
 }