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 460 forks source link

Rebuild doesn't check alias for parent_id #337

Closed sahamilton closed 4 years ago

sahamilton commented 4 years ago

v2.x-dev Rebuild fails with message Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'persons.parent_id' in 'where clause' (SQL: select count(*) as aggregate frompersonsleft outer joinpersonsAS parent onpersons.parent_id= parent.idwhere (persons.lftIS NULL OR persons.rgtIS NULL OR persons.lft>=persons.rgtOR (persons.parent_idIS NOT NULL AND (persons.lft<= parent.lftOR persons.rgt>= parent.rgt))) andpersons.deleted_atis null)'

where the model (in this casePerson) has an alias for the parent column: protected $parentColumn = 'reports_to';

sahamilton commented 4 years ago

OK My bad ... Looks like the parent column name has changed to parentColumnName vs parentColumn in prior version...