[CDBI] Many-to-Many - why no CDBI::Relationship?
"Ryan Tate" <lists-UNebACArQA1Wk0Htik3J/[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
Is there a reason no one has ever written a Class::DBI::Relationship subclass for many-to-many? The idea, of course, would be to get all objects related via a mapping table with a single database query (using a SQL join), including all Essential attributes. Right now, the has_many many-to-many hack only gets you the id of each related object, and you need to do a separate db query for each object if you want to flesh out the other attributes. Are most people happing writing custom SQL as needed? Or constructing the appropriate search query in Class::DBI::Sweet? As far as I can tell, Sweet can get many-to-many related objects with one query, but you have to construct the correct ->search. I recently wrote some general code that walks a class' has_manys and generates efficient accessors for those that are many-to-many. It was easier than I thought it would be, and beat having to write the six different set_sqls and custom accessors I needed. So I was just curious why no one has rolled this kind of thing into a full-blown relationship.