On 1/15/07, Cory Bennett <[EMAIL PROTECTED]> wrote: > Ahh, found the magic. > In Rose::DB::Object::Metadata::Relationship::OneToMany I found the special > (but buried) 'query_args' variable. So this will do what I want: > relationships => [ > prices => { > type => 'one to many', > class => 'Price', > column_map => { id => 'product_id' }, > query_args => [ > or => [ > enddate => undef, > enddate => { gt => 'now' }, > ], > ], > }, > ], > > Good stuff, thanks!
Be careful if you ever set this collection of related objects: $p->prices(@prices); Doing that will first delete any existing prices where prices.product_id = product.id and (enddate is null or enddate > 'now') before inserting the new rows. If that's what you want, fine, but just be aware of what it will actually do. (I'm probably going to add a "get" method type for relationships that does not allow the collection of related objects to be set, just to have a safer alternative in cases where you never plan to set the collection.) -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