laravel/framework · error · LogicException

This database engine does not support the updateFrom method.

Error message

This database engine does not support the updateFrom method.

What it means

updateFrom() emits the PostgreSQL-specific UPDATE ... FROM syntax. It first checks whether the connection's grammar implements compileUpdateFrom; only PostgresGrammar does. On MySQL/SQLite/SQL Server the method is unsupported and throws LogicException to prevent generating invalid SQL.

Solutions

  1. Switch the connection to pgsql (config('database.default') / DB::connection('pgsql')).
  2. Branch on driver and use the native idiom (e.g. ->join()->update() for MySQL, or upsert).
  3. In tests, use a Postgres-compatible driver instead of SQLite if the code path requires updateFrom().

Example fix

// before (default mysql connection)
->updateFrom(['col' => $val]);

// after
DB::connection('pgsql')->table('t')->updateFrom(['col' => $val]);
Defensive patterns

Strategy: validation

Validate before calling

if (! method_exists($query->getGrammar(), 'compileUpdateFrom')) {
    throw new RuntimeException('updateFrom requires a PostgreSQL connection.');
}
$query->updateFrom($values);

Prevention

When it happens

Trigger: Calling ->updateFrom($values) on a query backed by a MySQL, SQLite, or SQL Server connection.

Common situations: Running code originally written for Postgres against a different default connection; CI using SQLite while production uses Postgres; multi-database apps that did not branch on driver.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/5b775b3b17d46dde. Report an issue: GitHub.

Appendix: source

Thrown at src/Illuminate/Database/Query/Builder.php:4336

        $sql = $this->grammar->compileUpdate($this, $values->map(fn ($value) => $value['value'])->all());

        return $this->connection->update($sql, $this->cleanBindings(
            $this->grammar->prepareBindingsForUpdate($this->bindings, $values->map(fn ($value) => $value['bindings'])->all())
        ));
    }

    /**
     * Update records in a PostgreSQL database using the update from syntax.
     *
     * @return int
     *
     * @throws \LogicException
     */
    public function updateFrom(array $values)
    {
        if (! method_exists($this->grammar, 'compileUpdateFrom')) {
            throw new LogicException('This database engine does not support the updateFrom method.');
        }

        $this->applyBeforeQueryCallbacks();

        $sql = $this->grammar->compileUpdateFrom($this, $values);

        return $this->connection->update($sql, $this->cleanBindings(
            $this->grammar->prepareBindingsForUpdateFrom($this->bindings, $values)
        ));
    }

    /**
     * Insert or update a record matching the attributes, and fill it with values.
     *
     * @return bool
     */
    public function updateOrInsert(array $attributes, array|callable $values = [])
    {

View on GitHub (pinned to e0f6eb3518)