{"id":"5b775b3b17d46dde","repo":"laravel/framework","slug":"this-database-engine-does-not-support-the-updatefr","errorCode":null,"errorMessage":"This database engine does not support the updateFrom method.","messagePattern":"This database engine does not support the updateFrom method\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Query/Builder.php","lineNumber":4336,"sourceCode":"\n        $sql = $this->grammar->compileUpdate($this, $values->map(fn ($value) => $value['value'])->all());\n\n        return $this->connection->update($sql, $this->cleanBindings(\n            $this->grammar->prepareBindingsForUpdate($this->bindings, $values->map(fn ($value) => $value['bindings'])->all())\n        ));\n    }\n\n    /**\n     * Update records in a PostgreSQL database using the update from syntax.\n     *\n     * @return int\n     *\n     * @throws \\LogicException\n     */\n    public function updateFrom(array $values)\n    {\n        if (! method_exists($this->grammar, 'compileUpdateFrom')) {\n            throw new LogicException('This database engine does not support the updateFrom method.');\n        }\n\n        $this->applyBeforeQueryCallbacks();\n\n        $sql = $this->grammar->compileUpdateFrom($this, $values);\n\n        return $this->connection->update($sql, $this->cleanBindings(\n            $this->grammar->prepareBindingsForUpdateFrom($this->bindings, $values)\n        ));\n    }\n\n    /**\n     * Insert or update a record matching the attributes, and fill it with values.\n     *\n     * @return bool\n     */\n    public function updateOrInsert(array $attributes, array|callable $values = [])\n    {","sourceCodeStart":4318,"sourceCodeEnd":4354,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Query/Builder.php#L4318-L4354","documentation":"Thrown by updateFrom when the underlying grammar does not define compileUpdateFrom. The PostgreSQL FROM-style UPDATE (UPDATE t SET ... FROM other WHERE ...) is Postgres-specific; only PostgresGrammar implements it. Calling updateFrom on MySQL, SQLite, or SQL Server grammar is a programmer error, not a runtime data problem.","triggerScenarios":"Writing `DB::table('t')->join('u', ...)->updateFrom([...])` against MySQL. Running code in a test suite backed by SQLite when production is Postgres. Calling updateFrom inside a connection-agnostic helper that runs on multiple drivers.","commonSituations":"Local dev on SQLite/MySQL vs production Postgres; multi-tenant codebases where some tenants are on different DB drivers; copy-pasting Postgres-specific recipes into shared code.","solutions":["Switch to Postgres for that connection, or use the cross-driver `update()` with a join on grammars that support it.","Gate the call: `if (DB::getDriverName() === 'pgsql') { $q->updateFrom(...); } else { /* fallback */ }`.","Refactor to a driver-agnostic equivalent (two-step select-then-update, or whereIn with a subquery).","Ensure test DB matches production driver to surface the incompatibility early."],"exampleFix":"// before\nDB::table('users')\n    ->whereIn('id', fn ($q) => $q->select('user_id')->from('banned'))\n    ->updateFrom(['status' => 'banned']);\n// on MySQL => This database engine does not support the updateFrom method.\n\n// after\nDB::table('users')\n    ->whereIn('id', fn ($q) => $q->select('user_id')->from('banned'))\n    ->update(['status' => 'banned']);","handlingStrategy":"type-guard","validationCode":"if (! method_exists(DB::connection()->getQueryGrammar(), 'compileUpdateFrom')) {\n    throw new \\LogicException('Driver '.DB::getDriverName().' does not support updateFrom; use update() with a join or subquery.');\n}","typeGuard":"function driverSupportsUpdateFrom(\\Illuminate\\Database\\Connection $c): bool\n{\n    return method_exists($c->getQueryGrammar(), 'compileUpdateFrom');\n}","tryCatchPattern":"try {\n    $q->updateFrom($values);\n} catch (\\LogicException $e) {\n    if (str_contains($e->getMessage(), 'does not support the updateFrom')) {\n        // fall back to a driver-agnostic update with whereIn subquery\n        $q->update($values);\n    } else { throw $e; }\n}","preventionTips":["Align the test DB driver with production (use Postgres in CI if prod is Postgres).","Gate Postgres-only syntax behind a driver check in shared code.","Prefer driver-agnostic update()/join() unless you specifically need FROM semantics."],"tags":["query-builder","update","driver-incompatibility","postgres"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}