Skip to content

WithDepth() and Globalscope Joins doesnt work together #414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jennataiga opened this issue Oct 22, 2019 · 1 comment
Open

WithDepth() and Globalscope Joins doesnt work together #414

jennataiga opened this issue Oct 22, 2019 · 1 comment

Comments

@jennataiga
Copy link

jennataiga commented Oct 22, 2019

For example:
You have a UserService where you call withDepth() function and before that line of code is reached, your model user model gobal scope join is added to query. Then there is an error that coulmn xy is not found in table users.

UserModel:
$query->join('user_relation_clients', function ($join) use ($currentClientId) { $join->on('users.id', '=', 'user_relation_clients.user_id') ->where('user_relation_clients.client_id', $currentClientId); });

UserService:
$user->withDepth()->having('depth', '=', $this->request->get('depth'));

Error:
select *, (select count(1) - 1 from usersas_dinner joinuser_relation_clientsonusers.id=user_relation_clients.user_idanduser_relation_clients.auth_client_id= 2ea431c9-5218-4a96-89d2-587e441725ba whereusers._lftbetween_d._lftand_d._rgt) as depthfromusersinner joinuser_relation_clientsonusers.id=user_relation_clients.user_idanduser_relation_clients.auth_client_id= 2ea431c9-5218-4a96-89d2-587e441725ba whereis_published= 1 andusers._lftbetween 38 and 54 havingdepth= 1 order byorder_no asc

@lazychaser is there any workaround ?

@mackhankins
Copy link

I think there is a pull request yet to be merged for this.

#300

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

No branches or pull requests

2 participants