etrepat / baum

Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.
http://etrepat.com/baum
MIT License
2.24k stars 459 forks source link

Does it work with UUIDs? #287

Closed johlton closed 6 years ago

johlton commented 6 years ago

Hi there,

this may be a stupid question but does this work with UUIDs instead of autoincrementing integer IDs? I'm using Laravel 5.5 with webpatser/laravel-uuid and in my opinion it works quite well. What puzzles me (and both studied computer scientist in my office can't help me out):

Do the "lft" and "rgt" relate to integer IDs? And if so, how would I be able to adapt them to UUID usage?

If I switch the column type to text or UUID it still tries to insert integer values. In my Eloquent model I included

protected $casts = [
        'id' => 'string',
        'parent_id' => 'string',
        'lft' => 'string',
        'rgt' => 'string',
    ];

The rebuilding works (the integer values for "lft" and "rgt" and "depth" change) but I don't know for sure whether this is what SHOULD happen.

I had a look in Wikipedia and it seems that the values for "lft" and "rgt" are internal values for handling the hierarchy and have no relation to the node value (in my case the ID/UUID).

Sorry my confusion & Thanks in advance. Fabian