Does this make a difference? The docs explicitly have a lower-case left. In any event, I tried the upper case version and it still fails.
I might add, though I think some folks may have missed this, my initial email had a complete test case which you can cut-n-paste and run! (Assuming you have DBIx::Class::Schema::Loader and DBD::SQLite, that is :) I mention this because I'm hearing suggestions, but I went out of my way to make a runnable snippet for folks and no one is trying it :( Cheers, Ovid -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Tech blog - http://use.perl.org/~Ovid/journal/ Twitter - http://twitter.com/OvidPerl Official Perl 6 Wiki - http://www.perlfoundation.org/perl6 ----- Original Message ---- > From: Scott Pham (scpham) <[email protected]> > To: [email protected]; DBIx::Class user and developer list > <[email protected]>; Rob Kinyon <[email protected]> > Sent: Fri, 11 December, 2009 19:25:09 > Subject: RE: [Dbix-class] BUG? Unable to resolve relationship > > It looks like you are using 'left' not 'LEFT' in all caps? > > -----Original Message----- > From: Ovid [mailto:[email protected]] > Sent: Friday, December 11, 2009 10:53 AM > To: Rob Kinyon > Cc: DBIx::Class user and developer list > Subject: Re: [Dbix-class] BUG? Unable to resolve relationship > > (Apologies if this is sent twice) > > --- On Fri, 11/12/09, Rob Kinyon wrote: > > > From: Rob Kinyon > > > > Did you add the join_type => LEFT as I suggested? > > Yes. > > Trying to figure out the syntax. I *think* this is the correct syntax: > > The::Schema::Customer->belongs_to( > "account", "The::Schema::Account", > { "foreign.id" => "self.account_id" }, > { join_type => 'left' }, > ); > # The::Schema::Customer::account(): Unable to resolve relationship > # from Customer to account: column account.left 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 38 > > So I tried this: > > The::Schema::Customer->belongs_to( > "account", "The::Schema::Account", > { join_type => 'left' }, > { "foreign.id" => "self.account_id" } > ); > # The::Schema::Customer::account(): Unable to resolve relationship > # from Customer to account: column account.left 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 38 > > And flailing: > > The::Schema::Customer->belongs_to( > "account", > "The::Schema::Account", > { join_type => 'left', > "foreign.id" => "self.account_id" > }, > ); > # The::Schema::Customer::account(): Invalid rel cond key join_type > # at loader.pl line 38 > > I can't tell from the docs which I want, but this (from > DBIx::Class::Relationship) suggest that my first try might have been correct: > > # in a Book class (where Author has_many Books) > __PACKAGE__->belongs_to( > author => > 'My::DBIC::Schema::Author', > 'author', > { join_type => 'left' } > ); > > Also, you stated that "might_have is the LEFT JOIN version of has_many." The > docs say "one-to-one". Which is correct? Should I change my code from > might_have to belongs_to? (As I have above) > > Cheers, > Ovid > -- > Buy the book - http://www.oreilly.com/catalog/perlhks/ > Tech blog - http://use.perl.org/~Ovid/journal/ > Twitter - http://twitter.com/OvidPerl > Official Perl 6 Wiki - http://www.perlfoundation.org/perl6 > > > _______________________________________________ > 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] _______________________________________________ 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]
