staudenmeir / laravel-adjacency-list

Recursive Laravel Eloquent relationships with CTEs
MIT License
1.31k stars 106 forks source link

deleted_at field issue #246

Closed ilBronza closed 3 weeks ago

ilBronza commented 1 month ago

Hi, I'm using version "^1.12". I have a simple model with softdeletes, a (Ulid) parent_id and a (Ulid) id

when running $model->descendants()->get() I get a SQLSTATE[42S22] error

"with recursive laravel_cte as ((select , 0 as depth, cast(id as char(65535)) as path from filecabinets__filecabinets where parent_id is null) union all (select filecabinets__filecabinets., depth + 1 as depth, concat(path, ., filecabinets__filecabinets.id) from filecabinets__filecabinets inner join laravel_cte on laravel_cte.id = filecabinets__filecabinets.parent_id)) select * from laravel_cte where filecabinets__filecabinets.deleted_at is null"

filecabinets__filecabinets table has deleted_at field

model is just


class Test extends Model
{
    use CRUDUseUlidKeyTrait;
    use HasRecursiveRelationships;
    use SoftDeletes;

    public function getTable()
    {
        return 'filecabinets__filecabinets';
    }
}

when I comment the SoftDeletes trait I get the correct result

thank you

staudenmeir commented 1 month ago

Hi @ilBronza, Please share the whole error message.

What database and version are you using?