In SVN, I've just added a new method type to one-to-many relationships (no docs yet). Right now, I'm calling it "find". It's for fetching related objects using ad-hoc queries instead of being constrained to the mapping defined in the relationship metadata itself. It has no ability to "set" related objects; it just returns them. Here's an example using the Product/Price classes from the tutorial.
$p = Product->new(id => 123)->load; ## Example use of the default "get_set_on_save" method ## for the "prices" one-to-many relationship @prices = $p->prices; # get ... # modify @prices in some way $p->prices(@prices); # set... $p->save; # ...on save (db modified here) ## Example use of the new "find" method for the "prices" ## one-to-many relationship @high_prices = $p->find_prices(query => [ price => { gt => 99 } ], sort_by => 'region', ...any other manager args here...); @low_prices = $p->find_prices(query => [ price => { lt => 10 } ]); # Same as above (arrayref as first arg is taken as query) @low_prices = $p->find_prices([ price => { lt => 10 } ]); # Same as above (hashref as first arg is taken as query) @low_prices = $p->find_prices({ price => { lt => 10 } }); Every call to find_prices() goes back to the database to get new rows. Those rows are returned, not saved in the parent object ($p) at all. During each query, the mapping constraints defined in the relationship metadata that connect the parent object to its related objects are implicit, though they may be modified by conflicting, explicit arguments in the call. So, does this method type seem useful? If so, what do you think of the method type name ("find") and the default method name format ("find_<relationship-name>")? Finally, should this method type be created by default for all one-to-many relationships, or should it have to be manually requested in the relationship setup? -John ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object