Skip to content

Add selectable extraColumns to fixTree method#502

Open
walkingCommiter wants to merge 2 commits intolazychaser:v5from
walkingCommiter:v5
Open

Add selectable extraColumns to fixTree method#502
walkingCommiter wants to merge 2 commits intolazychaser:v5from
walkingCommiter:v5

Conversation

@walkingCommiter
Copy link

@walkingCommiter walkingCommiter commented Mar 22, 2021

This allows fixTree method select extra columns for model that require extra keys (for example cache key or cloud key) to work properly.

What happens:
In QueryBuilder:fixTree() method there is a section where the code is choosing the "to be selected" columns. This line raises an issue for us since our Entity requires an extra column to be selected or else the fix tree will fail when trying to load nodes in the next lines.

 public function fixTree($root = null)
    {
        $columns = [
            $this->model->getKeyName(),
            $this->model->getParentIdName(),
            $this->model->getLftName(),
            $this->model->getRgtName(),
            'cloud_id', // <--- our model needs this  cloud id to be properly loaded in case of passive caching
        ];

Expected Behavior:
The solution is rather simple. Just allow selecting extra columns as optional. No extra change is needed:

Here is the solution:

    public function fixTree($root = null, array $extra = [])
    {
        $columns = [
            $this->model->getKeyName(),
            $this->model->getParentIdName(),
            $this->model->getLftName(),
            $this->model->getRgtName(),
        ] // add  $extra to it;

This would solve our issue and possibly any other code that has multiple clouds.

#501

@aimeos
Copy link

aimeos commented Feb 6, 2026

This PR has been merged into https://github.com/aimeos/laravel-nestedset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants