Skip to content

Conversation

staudenmeir
Copy link
Contributor

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', 'p.id', '=', 'c.post_id')
    ->where('p.active', 0)
    ->update(['c.active' => 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
@staudenmeir staudenmeir deleted the update-alias branch August 4, 2019 13:19
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.

2 participants