[Dbix-class] BUG? Unable to resolve relationship

Peter Rabbitson rabbit+dbic at rabbit.us
Sat Dec 12 10:24:08 GMT 2009


Rob Kinyon wrote:
> On Fri, Dec 11, 2009 at 09:55, Ovid <publiustemp-dbic at yahoo.com> wrote:
> [snip]
>>    The::Schema::Customer->might_have( "account", "The::Schema::Account",
>           { "foreign.id" => "self.account_id" } );
>>    my $cust = $schema->resultset('Customer')->create( { name => 'john' } );
>>    print $cust->account->type;
>>
>> In DBIx::Class::VERSION 0.08010 (our current version at work), if you run this code and print $cust->account->type, and it prints "Premium", even though we have deliberately excluded an account.
>>
>> When I upgrade to 0.08115:
>>
>>  My::Schema::Customer::account(): Unable to resolve relationship from Customer to account: column account.account_id not loaded from storage (or not passed to new() prior to insert()). Maybe you forgot to call ->discard_changes to get defaults from the db. at loader.pl line 7
> 
> This looks to be the mythical "might_belong_to" relationship type that
> hasn't been defined yet. might_have is the LEFT JOIN version of
> has_many. What you want is belongs_to( ..., { join_type => 'LEFT' } );
> 

Where is the branch for might_belong_to ?



More information about the DBIx-Class mailing list