[CDBI] Many-to-Many - why no CDBI::Relationship?

Ryan Tate lists at ryantate.com
Mon Aug 21 19:46:06 BST 2006

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

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

More information about the ClassDBI mailing list