> After digging a little bit, I saw that when updating vendor, > it first deletes all products for this vendor and tries to add the new > ones. So far, so good. But all the objects retrieved using products() > method are in state "in_db" which means that they will be updated > (using SQL UPDATE) instead of INSERTed. Since thay are gone after > DELETE, the update silently fails.
Sounds like a bug. I'll look into it. > Also I understood that my approach isn't very effective so I'll use > the many-to-one relation of Product object in order to add one more > product for given vendor: > my $product = Product->new; > $product->vendor($vendor); # $vendor ISA 'Vendor' > $product->save(); If you just want to add to a one-to-many related list, you should use the "add_on_save" method. Continuing to use the tutorial example, it will be named add_products(): $vendor->add_products(Product->new); $vendor->save(); That will just add the new product, rather than deleting them all and then re-saving the entire list. You should only set products() when you really want to replace the entire list. (Of course, I still have to fix that bug to make that part work... :) -John ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object