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 DELETE queries with joins on PostgreSQL #29313

Merged
merged 1 commit into from Jul 29, 2019

Conversation

@staudenmeir
Copy link
Contributor

commented Jul 28, 2019

On PostgreSQL, Laravel implements DELETE queries with joins by adding their constraints after the WHERE constraints. If a query only has joins, the constraints aren't compiled:

DB::table('comments')
    ->join('posts', function ($join) {
        $join->on('posts.id', '=', 'comments.post_id')
            ->where('posts.active', 0);
    })
    ->delete();
# expected
delete from "comments" USING "posts"
where "posts"."id" = "comments"."post_id" and "posts"."active" = 0

# actual
delete from "comments" USING "posts"

@taylorotwell taylorotwell merged commit af46990 into laravel:5.8 Jul 29, 2019

2 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@staudenmeir staudenmeir deleted the staudenmeir:pgsql-delete branch Jul 29, 2019

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