laravel/framework · error · RuntimeException
This database driver does not support retrieving tables.
Error message
This database driver does not support retrieving tables.
What it means
Grammar::compileTables() is a RuntimeException stub on the base class. All four shipped grammars (SQLite, SQL Server, Postgres, MySQL) override it; reaching the base indicates the connection is using an unimplemented grammar. Builder::getTables() routes here, so any call to list tables hits this on an unsupported grammar.
Solutions
- Use a supported driver (sqlite/mysql/pgsql/sqlsrv).
- In your custom grammar, override compileTables($schema) to return the engine's table-listing SQL.
- Query information_schema directly with DB::select() as a stopgap.
Example fix
// before - throws on base grammar
$tables = Schema::connection('custom')->getTables();
// after - implement compileTables in CustomGrammar, or fall back to raw SQL
$tables = DB::connection('custom')->select(
"SELECT name FROM sqlite_master WHERE type='table'"
); 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 tables.');
} Type guard
function supportsCompileTables(\Illuminate\Database\Schema\Grammars\Grammar $grammar): bool
{
return (new \ReflectionMethod($grammar, 'compileTables'))
->getDeclaringClass()->getName() !== \Illuminate\Database\Schema\Grammars\Grammar::class;
} Try / catch
try {
$tables = Schema::getTables();
} catch (\RuntimeException $e) {
if (str_contains($e->getMessage(), 'retrieving tables')) {
$tables = DB::select("SELECT name FROM sqlite_master WHERE type='table'");
} else {
throw $e;
}
} Prevention
- Bind a concrete grammar in custom driver connections.
- In admin/inspection tools, detect the grammar class before listing tables.
- Cover all compile* overrides when authoring a new grammar, not just the migration-critical ones.
When it happens
Trigger: Schema::getTables() or Schema::hasTable() (which internally calls compileTables via the table-existence path on some drivers) on a connection whose SchemaGrammar is the base Grammar. Commonly a custom driver whose Connection does not provide a real grammar.
Common situations: Third-party driver bridge returning a base Grammar; test setup that does not bind a concrete grammar; an engine whose integration was started but whose grammar methods were never filled in.
Related errors
- The database driver in use does not support vector indexes.
- This database driver does not support dropping foreign keys.
- This database driver does not support fulltext index…
- This database driver does not support fulltext index…
- This database driver does not support modifying columns.
AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11).
Data as JSON: /api/errors/a83d6a795fb69e55.
Report an issue: GitHub.
Appendix: source
Thrown at src/Illuminate/Database/Schema/Grammars/Grammar.php:100
* @param string $table
* @return string|null
*/
public function compileTableExists($schema, $table)
{
//
}
/**
* Compile the query to determine the tables.
*
* @param string|string[]|null $schema
* @return string
*
* @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.
*View on GitHub (pinned to e0f6eb3518)