From: David Kamholz Date: Thu, 26 Jan 2006 15:32:25 +0000 (+0000) Subject: - fix recent belongs_to changes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=35c2ee73e62f1b99d956a874f87d75230f9b07a9;p=dbsrgits%2FDBIx-Class-Historic.git - fix recent belongs_to changes - revert accessor in basicrels --- diff --git a/lib/DBIx/Class/Relationship/BelongsTo.pm b/lib/DBIx/Class/Relationship/BelongsTo.pm index 326a99a..093d0be 100644 --- a/lib/DBIx/Class/Relationship/BelongsTo.pm +++ b/lib/DBIx/Class/Relationship/BelongsTo.pm @@ -45,7 +45,7 @@ sub belongs_to { } $cond_rel->{"foreign.$_"} = "self.".$cond->{$_}; } - my $acc_type = (scalar keys %$cond_rel == 1) ? 'filter' : 'single'; + my $acc_type = (keys %$cond_rel == 1 and $class->has_column($rel)) ? 'filter' : 'single'; $class->add_relationship($rel, $f_class, $cond_rel, { accessor => $acc_type, %{$attrs || {}} } diff --git a/t/lib/DBICTest/Schema/BasicRels.pm b/t/lib/DBICTest/Schema/BasicRels.pm index 9894bb9..a3e7279 100644 --- a/t/lib/DBICTest/Schema/BasicRels.pm +++ b/t/lib/DBICTest/Schema/BasicRels.pm @@ -71,14 +71,12 @@ DBICTest::Schema::SelfRef->add_relationship( DBICTest::Schema::Tag->add_relationship( cd => 'DBICTest::Schema::CD', - { 'foreign.cdid' => 'self.cd' }, - { accessor => 'single' } + { 'foreign.cdid' => 'self.cd' } ); DBICTest::Schema::Track->add_relationship( cd => 'DBICTest::Schema::CD', - { 'foreign.cdid' => 'self.cd' }, - { accessor => 'single' } + { 'foreign.cdid' => 'self.cd' } ); DBICTest::Schema::TwoKeys->add_relationship(