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

[5.4] Fix JoinClause's whereIn when using a subquery #20453

Merged
merged 3 commits into from
Aug 14, 2017
Merged

[5.4] Fix JoinClause's whereIn when using a subquery #20453

merged 3 commits into from
Aug 14, 2017

Conversation

rtheunissen
Copy link
Contributor

@rtheunissen rtheunissen commented Aug 7, 2017

Description:

You should be able to pass an existing Builder to whereIn of a JoinClause, but this doesn't work because the if ($values instanceof static) doesn't catch the expected case when you pass a Builder because it's not an instance of JoinClause.

TypeError: Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, object given

Steps To Reproduce:

/** @var Illuminate\Database\Query $query */
$query = $this->getFieldQuery(); 

Account::join('other_table', function (JoinClause $join) use ($query) {
    return $join->on('other_table.field', '=', 'accounts.field')
                ->whereIn('other_table.field', $query);
});

@tillkruss tillkruss changed the title Fix JoinClause's whereIn when using a subquery [5.4] Fix JoinClause's whereIn when using a subquery Aug 7, 2017
@rtheunissen
Copy link
Contributor Author

Thoughts on this @taylorotwell? We currently can't use subqueries in joins resulting in more queries than we'd like to be making. Should we use a fork in the meantime (rather than modified vendor files) or can we look at releasing this as a patch on 5.4?

@taylorotwell taylorotwell merged commit 162fe7d into laravel:5.4 Aug 14, 2017
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.

2 participants