Skip to content
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

Laravel 5.1 polymorphic whereHas, only trashed. #13198

Closed
erdemkeren opened this issue Apr 18, 2016 · 2 comments
Closed

Laravel 5.1 polymorphic whereHas, only trashed. #13198

erdemkeren opened this issue Apr 18, 2016 · 2 comments

Comments

@erdemkeren
Copy link

dd($self->bar()->onlyTrashed()->whereHas('qux', function ($query) {
                $query->onlyTrashed()->where('foo', 'bar');
})->toSql());

Generates:

select * from `bars` where `bars`.`owner_id` = ? and `bars`.`owner_id` is not null and `bars`.`owner_type` = ? and `bars`.`deleted_at` is not null and (select count(*) from `quxes` where `bars`.`qux_id` = `quxes`.`id` and `quxes`.`deleted_at` is not null and `foo` = ? and `quxes`.`deleted_at` is null) >= 1

To be clear;

quxes.deleted_at is not null and quxes.deleted_at is null

Looks like a bug to me.

@themsaid
Copy link
Member

themsaid commented Sep 6, 2016

Fixed via the PR.

@themsaid themsaid closed this as completed Sep 6, 2016
@ryun
Copy link
Contributor

ryun commented Nov 29, 2016

@themsaid This is still not fixed for 5.1

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

3 participants