On 5/18/07, Derek Watson <[EMAIL PROTECTED]> wrote: > Am I modeling this wrong? How can I get Rose to archive the previous > $a->b when I say $a->b($new_b_record)? Or at least try to save the new > 'b' record so that my DB will throw an error about a clashing unique > key?
A ...-to-one expects there to just be one thing at the end. So there's no "add" method, just get and set. A set implies replacing the existing one with a new one, which is what you're seeing: RDBO deletes the old and inserts the new. To get the behavior you want, I think you'll need to use a 1-to-many and then wrap the relationship accessor in such a way that a set is really an add. sub b { my($self) = shift; $self->add_bs(@_) if(@_); # bs must be sorted so that the last one is the latest one # use manager_args on the "bs" rel to do that. my $bs = $self->bs || []; return $bs->[-1]; } Then add a trigger to the b table (or the My::B class) to handle the "archiving" or a previous b record when a new one is inserted. -John ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object