laravel/framework · error · RuntimeException

This database driver does not support retrieving views.

Error message

This database driver does not support retrieving views.

What it means

Base Grammar::compileViews() throws RuntimeException because the driver's grammar does not override it. It powers Schema::getViews(); drivers with a view catalogue (Postgres, MySQL, SQL Server) override it. SQLite and incomplete custom drivers do not.

Source

Thrown at src/Illuminate/Database/Schema/Grammars/Grammar.php:113

     *
     * @throws \RuntimeException
     */
    public function compileTables($schema)
    {
        throw new RuntimeException('This database driver does not support retrieving tables.');
    }

    /**
     * Compile the query to determine the views.
     *
     * @param  string|string[]|null  $schema
     * @return string
     *
     * @throws \RuntimeException
     */
    public function compileViews($schema)
    {
        throw new RuntimeException('This database driver does not support retrieving views.');
    }

    /**
     * Compile the query to determine the user-defined types.
     *
     * @param  string|string[]|null  $schema
     * @return string
     *
     * @throws \RuntimeException
     */
    public function compileTypes($schema)
    {
        throw new RuntimeException('This database driver does not support retrieving user-defined types.');
    }

    /**
     * Compile the query to determine the columns.
     *

View on GitHub (pinned to bd6b5437e6)

Solutions

  1. Use a driver whose grammar overrides compileViews (pgsql/mysql/sqlsrv).
  2. Query the engine's view catalogue directly on unsupported drivers.
  3. Guard the call by driver type before invoking.

Example fix

// before
$views = Schema::getViews();

// after — guard by supported driver
$ok = ['pgsql', 'mysql', 'sqlsrv'];
$views = in_array(DB::connection()->getDriverName(), $ok, true) ? Schema::getViews() : [];
Defensive patterns

Strategy: type-guard

Validate before calling

$driver = DB::connection()->getDriverName();
if (! in_array($driver, ['pgsql','mysql','sqlsrv'], true)) {
    return [];
}
return Schema::getViews();

Type guard

function driverSupportsViewListing(): bool
{
    return in_array(DB::connection()->getDriverName(), ['pgsql','mysql','sqlsrv'], true);
}

Try / catch

try {
    $views = Schema::getViews();
} catch (\RuntimeException $e) {
    $views = [];
}

Prevention

When it happens

Trigger: Calling Schema::getViews() on SQLite or a custom driver whose grammar lacks the override.

Common situations: Cross-driver introspection utility that calls getViews() unconditionally; test fixtures using SQLite but migrations referencing views.

Related errors


AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06). Data as JSON: /data/errors/eecff4e11467825b.json. Report an issue: GitHub.