gabordemooij/redbean — Issue #100: single nested bean modification issue
Author: gabordemooij
Created: 2011-11-04 23:23:06+00:00
State: open

"Of course you can also change buildings in the list"
Well you can for this type of relationship mapping, but this does not work with "nested" bean mapping in the previous example.
The penultimate line below will NOT change the value of the related field:
$farm = R::dispense('building');
$village = R::dispense('village') ;
$village->name = 'potterville' ;
$farm->village = $village ;
$id = R::store($farm) ;
$farm = R::load('building',$id);
$farm->village->name = 'somewheresville' ;
$id = R::store($farm) ;

Unit test to reproduce (in n1test.php)

$farm = R::dispense('building');
$village = R::dispense('village') ;
$village->name = 'potterville' ;
$farm->village = $village ;
$id = R::store($farm);

$farm = R::load('building',$id);
$farm->name = 123;
$farm->village->name = 'somewheresville';
asrt($farm->village->name,'somewheresville');
$id = R::store($farm);
$f=R::load('building',$id);
asrt($farm->village->name,'somewheresville');

proves fix