Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:5.8from
staudenmeir:alias-prefix
May 3, 2019
Merged

[5.8] Fix fromSub() and joinSub() with table prefix#28400
taylorotwell merged 1 commit into
laravel:5.8from
staudenmeir:alias-prefix

Conversation

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