Hello,
What is the recommended idiom for deleting a single object from a
one-to-many relationship? Using the textbook example,
$p = Product->new(name => 'Kite');
$p->prices({ price => 1.23, region => 'US' },
{ price => 4.56, region => 'UK' });
$p->save; # database is modified here
How would I go about deleting only the UK price? The following seems to
delete the UK price record, but leaves it in the collection of $p->prices.
my ($price) = grep { $_->region eq 'UK' } $p->prices;
$price->delete;
Should I also be calling $p->save? Or should I be doing something more like
this?
my @prices = grep { $_->region ne 'UK' } $p->prices;
$p->prices(@prices);
$p->save;
Is there a more explicit way to do what I'm after without resorting to this
grep business? I remember talk a couple weeks back about
$p->find_prices(region => 'UK') functionality. Will this be included in a
release sometime soon? I'd prefer not to resort to a Manger call, because
then I need to repeat the expression of the relationship (--DRY).
Cheers,
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object