[Dbix-class] joins -- Can't Handle this Yet?
Brandi Cantarel
b.cantarel at gmail.com
Wed Oct 29 06:29:11 GMT 2008
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');
my $schema = Cazy::Schema;
my $entry_rs = $schema->resultset('Entry');
my $entryorg_rs = $schema->resultset('EntryOrgname');
my $query1 = $entryorg_rs->search(\%where,{join=>'entry'});
###DOESN'T WORK -- Throws error "Can't Handle This Yet"
my $query1 = $entry_rs->search(\%where,{join=>'entry_orgname'});
###DOES WORK
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']
});
Is there a solution, without having to break up this query?
Brandi
On Oct 28, 2008, at 10:43 PM, Cory Watson wrote:
> On 10/28/08, Brandi Cantarel <b.cantarel at gmail.com> wrote:
>> I would like to join 2 tables using DBIx::Class but I get this error:
>>
>> Can't handle this yet :(
>>
>> when my starting table "belongs" to the second table?? I don't
>> understand, can I only join starting from tables where that table is
>> the owner of the primary key from which to join? I would actually
>> like to join many tables and would like to start the join with this
>> "belongs_to" table as I would if I were using simple DBI.
>>
>> There is a one to one relationship between the two tables I would
>> like to join.
>>
>>
>> BTW, does anyone know how to "print" the SQL the program is
>> producing. Sometimes I get errors and I feel like looking at the
>> actual SQL would help alot.
>
>
> Hi Brandi,
>
> I think you might want to take a look at the DBIx::Class Cookcook:
>
> http://search.cpan.org/perldoc?DBIx::Class::Manual::Cookbook
>
> The "JOINS AND PREFETCHING" and "DEBUGGING AND PROFILING" sections
> should get you going in the right direction!
>
> --
> Cory 'G' Watson
> http://www.onemogin.com
>
> _______________________________________________
> 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/dbix-
> class at lists.scsys.co.uk
More information about the DBIx-Class
mailing list