On Jan 10, 2008 10:01 AM, Curon Davies <[EMAIL PROTECTED]> wrote: > Hi John. Thanks for your help on this. Unfortunately that still > doesn't quite work. If we do: > > $product = My::DB::Product->new(name => $^T); > $product->add_prices( > { price => 3.60, region => 'uk' }, > { price => 7.00, region => 'us' }, > ); > > and then: > > my @prices = $product->prices; > > @prices is empty.
Yeah, because it's not sure that $product doesn't already exist in the database with an existing set of prices, so the actual list of prices is still unknown. (It's keeping the list of prices-to-add off to the side, awaiting save().) To make it sure that there are really no other prices, you either have to fetch them from the db (which requires defined values for the local columns that participate in the "prices" one-to-many relationship) or you have to set them. (Even setting to an empty list [] would work.) Of course, the setting option gets you right back to where you started, so that's no good :) > After calling new, I need to be able to access the objects created > when passed with the 'add_prices' parameter, in a different (custom) > method before saving the objects into the database. Why not fiddle with the prices objects *before* passing them to add_prices()? > Is there any way we can retain this functionality while not requiring > DELETE database privileges? I'm open to suggestions. Can anyone think of a good way to make this work without breaking some existing functionality? -John ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object