[Dbix-class] joins -- Can't Handle this Yet?

Jess Robinson castaway at desert-island.me.uk
Thu Oct 30 12:54:45 GMT 2008


On Wed, 29 Oct 2008, Brandi Cantarel wrote:

> Thanks Cory for your response, but I am quite familiar with all of the online 
> help.
> After already consulting this and being able to write lots and lots of good 
> statements.  I have noticed that when use the table object and join it to a 
> table it "belongs_to"  I get the "Can't handle this error"
>
> But if I do the opposite join I do not get the error.  Why??
>
> __PACKAGE__->belongs_to('entry' => 'Cazy::Schema::Entry','entry_id');
> __PACKAGE__->add_relationship('entry' => 'Cazy::Schema::Entry','entry_id');
> __PACKAGE__->might_have('entry_orgname' => 
> 'Cazy::Schema::EntryOrgname','entry_id');
> __PACKAGE__->add_relationship('entry_orgname' => 
> 'Cazy::Schema::EntryOrgname','entry_id');

Somehow youre relationship is getting set with a condition that is neither 
a hashref nor an arrayref. Those "add_relationship" calls are incorrect 
for example. The "belongs_to" call on its own should produce a correct 
relationship condition.

Would you please send your entire schema class file, instead of parts of 
it? Both the one the relationship is in, and the Entry.pm one. It's very 
hard to help debug with just bits of info.

You can also check what the relationship condition is by doing:

print Dumper($schema->source('XXX')->relationship_info('entry')->{cond};

If that is not a hashref of an array, you did something wrong somewhere.


> my $query1 = $entryorg_rs->search(\%where,{join=>'entry'});  ###DOESN'T WORK

This should work fine if the relationship definitions are correct.

> What I would really like to do is this statement:
>
> my $query1 = $entryorg_rs->search(\%where,{
>                                              join=>{'entry'=>{'fam_comp'=>'family'}}
>                                              '+select'=>['entry.description','entry.note','entry.tax_id','entry.genome_id',
>                                                          'family.fam_acc','family.subf','fam_comp.seq_begin','fam_comp.seq_end'],
>                                              '+as'=>['entry_desc','entry_note','taxid','genome_id','fam_acc','subf','begin','end']
>                                             });
>


This one looks ok too.

Jess




More information about the DBIx-Class mailing list