yiiext / nested-set-behavior

AR models behavior that allows to work with nested sets tree.
http://www.yiiframework.com/extension/nestedsetbehavior/
BSD 3-Clause "New" or "Revised" License
157 stars 64 forks source link

While getting parent of node: if it is new and unsaved node - parent ... #7

Closed bethrezen closed 12 years ago

bethrezen commented 12 years ago

While getting parent of node: if it is new and unsaved node - parent can't be retrieven, because we don't have rgt and lft

cebe commented 12 years ago

shouldn't we throw an exception to complain about the unsaved record instead of returning null? Didn't check that in detail but when parent is null I'd interpret it as if it's a root node.

bethrezen commented 12 years ago

Maybe you are right

creocoder commented 12 years ago

Wontfix. It can be useful in next scenario:

$model=new Category;
$model->lft=2;
$model->rgt=7;
$model->parent()->find();

like native feature of framework:

$model=new Foo;
$model->bar_id=1;
$model->bar; // returns bar relation