gshank / dbix-class-resultset-recursiveupdate

DBIx::Class::ResultSet::RecursiveUpdate
4 stars 9 forks source link

belongs_to fails when table also defines a might_have with parent #14

Open ryleyb opened 5 years ago

ryleyb commented 5 years ago

The expected behaviour is for the row outputted from recursive_update to correctly show the nested belongs_to relationship. The actual behaviour is that it seems to lose the change in the returned row, despite correctly updating the DB.

This patch adds a test and changes a couple test schema tables:

In the test, I've added comments where you can comment out a line to make the test pass. When I dug into the RecursiveUpdate code, in _update_relation when it calls set_from_related, it passes in the correct data, but the output from get_columns afterwards is unchanged, for example:

$sub_object->get_columns() = {
          'dvd_id' => 5,
          'notes' => 'test note',
          'liner_notes_belongs_to' => 1
        };
Now $object->set_from_related($name, $sub_object) is called and then:
$sub_object->get_columns() = {
          'dvd_id' => 5,
          'notes' => 'test note',
          'liner_notes_belongs_to' => undef
        };

I tried a simpler test with just the liner_notes and liner_notes_belongs_to, but they worked fine... It only stops working when I add the extra layer of the DVD.