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 1 commit into from May 3, 2019


None yet
3 participants
Copy link

commented May 3, 2019

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', '')->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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

@staudenmeir staudenmeir deleted the staudenmeir:alias-prefix branch May 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.