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 UPDATE queries with alias #29405

merged 1 commit into from Aug 4, 2019


Copy link

commented Aug 3, 2019

PostgreSQL and SQLite don't support UPDATE queries with qualified column names in the SET clause.

We are already removing the table name, but that doesn't work with an alias:

DB::table('comments as c')
    ->join('posts as p', '', '=', 'c.post_id')
    ->where('', 0)
    ->update(['' => 0]);
update "comments" as "c" set "c"."active" = 0
from "posts" as "p"^         ^^^^
where "p"."active" = 0 and "p"."id" = "c"."post_id"

We can cover both cases by just taking everything after the dot.

@taylorotwell taylorotwell merged commit 22e9a9e into laravel:5.8 Aug 4, 2019

2 checks passed

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

@staudenmeir staudenmeir deleted the staudenmeir:update-alias branch Aug 4, 2019

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