On Fri, Dec 11, 2009 at 09:55, Ovid <[email protected]> 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' } );
Rob
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]