laravel/framework · error · RuntimeException

This database driver does not support retrieving…

Error message

This database driver does not support retrieving user-defined types.

What it means

Grammar::compileTypes() throws RuntimeException on the base class and is overridden ONLY by PostgresGrammar. User-defined types (Postgres enums, composites, domains) are a Postgres-specific concept; SQLite, SQL Server, and MySQL grammars inherit the throwing stub. Builder::getTypes() routes here, so calling it on any non-Postgres supported driver throws.

Solutions

  1. Gate getTypes() on the connection being Postgres (\Illuminate\Database\PostgresConnection).
  2. On other engines, query the engine-specific type catalog directly if one exists, or skip the call.
  3. If you maintain a custom driver with user-defined types, override compileTypes() in its grammar.

Example fix

// before - throws on MySQL/SQLite/SQL Server
foreach (array_keys(config('database.connections')) as $conn) {
    $types = Schema::connection($conn)->getTypes();
}

// after
use Illuminate\Database\PostgresConnection;
foreach (array_keys(config('database.connections')) as $conn) {
    if (DB::connection($conn) instanceof PostgresConnection) {
        $types[$conn] = Schema::connection($conn)->getTypes();
    }
}
Defensive patterns

Strategy: type-guard

Validate before calling

use Illuminate\Database\PostgresConnection;

if (Schema::getConnection() instanceof PostgresConnection) {
    $types = Schema::getTypes();
} else {
    // user-defined types are Postgres-only; nothing to introspect
}

Type guard

use Illuminate\Database\PostgresConnection;

function supportsGetTypes(\Illuminate\Database\Connection $connection): bool
{
    return $connection instanceof PostgresConnection;
}

Try / catch

try {
    $types = Schema::getTypes();
} catch (\RuntimeException $e) {
    if (str_contains($e->getMessage(), 'user-defined types')) {
        $types = []; // not applicable on this engine
    } else {
        throw $e;
    }
}

Prevention

When it happens

Trigger: Schema::getTypes() invoked on a MySQL, SQLite, or SQL Server connection (or any non-Pgsql custom grammar). Reachable from admin/inspection tooling that assumes every engine exposes a type catalog.

Common situations: An admin panel or migration analyzer that calls getTypes() on every connection; copying a Postgres introspection routine onto MySQL; a generic database documentation generator iterating all connections.

Related errors


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

Appendix: source

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

     *
     * @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.
     *
     * @param  string|null  $schema
     * @param  string  $table
     * @return string
     *
     * @throws \RuntimeException
     */
    public function compileColumns($schema, $table)
    {
        throw new RuntimeException('This database driver does not support retrieving columns.');
    }

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

View on GitHub (pinned to e0f6eb3518)