Skip to content

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

Merged
taylorotwell merged 3 commits intolaravel:5.4from
rtheunissen:rt-fix-join-wherein
Aug 14, 2017
Merged

[5.4] Fix JoinClause's whereIn when using a subquery#20453
taylorotwell merged 3 commits intolaravel:5.4from
rtheunissen:rt-fix-join-wherein

Conversation

@rtheunissen
Copy link
Copy Markdown
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
Copy Markdown
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