Skip Menu |

This queue is for tickets about the Rose-DB-Object CPAN distribution.

Report information
The Basics
Id: 93531
Status: resolved
Priority: 0/
Queue: Rose-DB-Object

Owner: Nobody in particular
Requestors: JDeVuyst [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.811

Subject: map_record_method shenanigans
Date: Wed, 5 Mar 2014 01:16:03 +0000
To: "bug-Rose-DB-Object [...]" <bug-Rose-DB-Object [...]>
From: "DeVuyst, Justin D" <JDeVuyst [...]>
Download (untitled) / with headers
text/plain 1.7k
Hello, We recently added: manager_args => { with_map_records => 1, }, to a many-to-many relationship, lets call it bar, in one of our classes and after that we were unable to set bar() with bar objects that were created through the rel like so: $obj2->bar( $obj1->bar); But using hash forms of the related objects works fine as well as bar objects that were not sourced through the rel. What seems to be happening is that the primary keys of the old map_records and their "in_db" state are not being cleared out. This results in a new map_record never being saved in the db because rose thinks it already exists, in a way. Here's a hacky and minimal fix I worked up that solves our particular manifestation of the bug: <snip> @@ -5421,7 +5421,18 @@ # Create or retrieve map record, connected to self if($map_record_method) { - $map_record = $object->$map_record_method() || $map_class->new; + $map_record = $object->$map_record_method(); + if ( $map_record ) { + foreach my $method ($map_record->meta->primary_key_column_mutator_names) + { + $map_record->$method(undef); + } + $map_record->{STATE_IN_DB()} = 0; + } + else + { + $map_record = $map_class->new; + } $map_record->init(%method_map_to_self, db => $db); } else </snip> We are using RDBO version 0.784. In addition to clearing the primary keys perhaps all other columns not associated with the map classes should be cleared as well - for consistency. Afterall, that's what happens when map_record_method isn't involved in the operation. Thanks, jdv
This should be fixed in 0.811, just uploaded to CPAN.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to