On Thu, 31 May 2007, Benoit Plessis wrote:
hi everyone,
Hiho
I'm knew to DBIx::Class (discovered with the Catalyst framework) but
i think it's terrible !
Errm, did that mean good?
Anyway i encountered two gotchas while using the thing and here they are:
1/ Relationships.
Let's say we have 3 tables and two relation:
table1.rel1 is a *might_have* on table2
table2.rel2 is a *belongs_to* on table3
Would you paste the actual fields, FKs etc, so we can make sure you got
"belongs_to" and "might_have" right ?
when doing someting like that:
$schema->resultset('Table1') -> search (undef, { prefetch => { 'table2' =>
'table3' } });
the generated SQL code will be something like that:
/FROM table1 LEFT JOIN table2 ON (table1.f1 = table2.f1) JOIN table3 ON
(table2.f2 = table3.f2)
Yes, you can change the default type of JOIN by using "join_type" in the
relationship attributes (see docs).
No idea about the performance stuff, tho the more complex your prefetch
queries, the more work DBIC will have to do to untangle the results back
in to objects..
Jess
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/