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.8] Fix fromSub() and joinSub() with table prefix #28400

Merged
merged 1 commit into from
May 3, 2019
Merged

[5.8] Fix fromSub() and joinSub() with table prefix #28400

merged 1 commit into from
May 3, 2019

Conversation

staudenmeir
Copy link
Contributor

The subquery alias in fromSub() and joinSub() has to include the table prefix:

'sqlite' => [
    'driver' => 'sqlite',
    'database' => ':memory:',
    'prefix' => 'prefix_',
],

DB::table('users')->joinSub(DB::table('posts'), 'alias', 'alias.user_id', 'users.id')->get();

// expected
select * from "prefix_users"
inner join (select * from "prefix_posts") as "prefix_alias"
on "prefix_alias"."user_id" = "prefix_users"."id"

// actual
select * from "prefix_users"
inner join (select * from "prefix_posts") as "alias"
on "prefix_alias"."user_id" = "prefix_users"."id"

Fixes #28391.

@taylorotwell taylorotwell merged commit 06f0fab into laravel:5.8 May 3, 2019
@staudenmeir staudenmeir deleted the alias-prefix branch May 3, 2019 14:30
franzliedke added a commit to flarum/framework that referenced this pull request May 9, 2020
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.

joinSub bug with table prefix
3 participants