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

Grammar::compileViews() throws RuntimeException on the base class. SQLiteGrammar, SqlServerGrammar, PostgresGrammar, and MySqlGrammar override it; reaching the base means no driver-specific grammar is bound. Builder::getViews() routes here.

Solutions

  1. Run getViews() only on connections backed by sqlite/mysql/pgsql/sqlsrv grammars.
  2. Override compileViews() in your custom grammar.
  3. Query the engine's view catalog (information_schema.views, pg_views) directly.

Example fix

// before
$views = Schema::connection('custom')->getViews();

// after
$views = DB::connection('custom')->select("SELECT table_name FROM information_schema.views");
Defensive patterns

Strategy: type-guard

Validate before calling

$grammar = Schema::getConnection()->getSchemaGrammar();
if (get_class($grammar) === \Illuminate\Database\Schema\Grammars\Grammar::class) {
    throw new \DomainException('Connection uses the base Grammar; cannot list views.');
}

Type guard

function supportsCompileViews(\Illuminate\Database\Schema\Grammars\Grammar $grammar): bool
{
    return (new \ReflectionMethod($grammar, 'compileViews'))
        ->getDeclaringClass()->getName() !== \Illuminate\Database\Schema\Grammars\Grammar::class;
}

Try / catch

try {
    $views = Schema::getViews();
} catch (\RuntimeException $e) {
    if (str_contains($e->getMessage(), 'retrieving views')) {
        $views = DB::select('SELECT table_name FROM information_schema.views');
    } else {
        throw $e;
    }
}

Prevention

When it happens

Trigger: Schema::getViews() on a connection whose SchemaGrammar is the base Grammar (custom driver not implementing the method).

Common situations: Custom/in-progress driver whose grammar does not override compileViews; an inspection/admin tool that calls getViews() across every configured connection regardless of engine support.

Related errors


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

Appendix: 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 e0f6eb3518)