{"id":"5e3c80fa29381142","repo":"laravel/framework","slug":"this-database-driver-does-not-support-retrieving-s","errorCode":null,"errorMessage":"This database driver does not support retrieving schemas.","messagePattern":"This database driver does not support retrieving schemas\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Schema/Grammars/Grammar.php","lineNumber":75,"sourceCode":"     * @return string\n     */\n    public function compileDropDatabaseIfExists($name)\n    {\n        return sprintf('drop database if exists %s',\n            $this->wrapValue($name)\n        );\n    }\n\n    /**\n     * Compile the query to determine the schemas.\n     *\n     * @return string\n     *\n     * @throws \\RuntimeException\n     */\n    public function compileSchemas()\n    {\n        throw new RuntimeException('This database driver does not support retrieving schemas.');\n    }\n\n    /**\n     * Compile the query to determine if the given table exists.\n     *\n     * @param  string|null  $schema\n     * @param  string  $table\n     * @return string|null\n     */\n    public function compileTableExists($schema, $table)\n    {\n        //\n    }\n\n    /**\n     * Compile the query to determine the tables.\n     *\n     * @param  string|string[]|null  $schema","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Schema/Grammars/Grammar.php#L57-L93","documentation":"Base Grammar::compileSchemas() throws RuntimeException because the driver's grammar does not override it. compileSchemas builds the information-schema query that backs Schema::getSchemas(); only drivers whose grammar overrides it (notably SQL Server) can list schemas. It signals a feature not implemented for this driver.","triggerScenarios":"Calling Schema::getSchemas() (or any path that calls Builder::getSchemas -> Grammar::compileSchemas) on a driver whose grammar lacks the override.","commonSituations":"Using getSchemas() with SQLite or MySQL where schema listing is unsupported; cross-driver code that assumed all drivers enumerate schemas.","solutions":["Use a driver whose grammar overrides compileSchemas (e.g. sqlsrv).","Avoid Schema::getSchemas() on unsupported drivers; fall back to a manual query against the engine's catalogue.","Guard the call by checking the connection/grammar type before invoking."],"exampleFix":"// before\n$schemas = Schema::getSchemas();\n\n// after\nif (method_exists(Schema::getConnection()->getSchemaGrammar(), 'compileSchemas')\n    && (new \\ReflectionMethod(Schema::getConnection()->getSchemaGrammar(), 'compileSchemas'))->getDeclaringClass()->getName()\n        !== \\Illuminate\\Database\\Schema\\Grammars\\Grammar::class) {\n    $schemas = Schema::getSchemas();\n} else {\n    $schemas = null; // unsupported on this driver\n}","handlingStrategy":"type-guard","validationCode":"$grammar = Schema::getConnection()->getSchemaGrammar();\nif ((new \\ReflectionMethod($grammar, 'compileSchemas'))->getDeclaringClass()->getName()\n    === \\Illuminate\\Database\\Schema\\Grammars\\Grammar::class) {\n    return null; // unsupported\n}\nreturn Schema::getSchemas();","typeGuard":"function driverSupportsSchemaListing(): bool\n{\n    $g = Schema::getConnection()->getSchemaGrammar();\n\n    return (new \\ReflectionMethod($g, 'compileSchemas'))\n        ->getDeclaringClass()->getName() !== \\Illuminate\\Database\\Schema\\Grammars\\Grammar::class;\n}","tryCatchPattern":"try {\n    $schemas = Schema::getSchemas();\n} catch (\\RuntimeException $e) {\n    $schemas = null; // unsupported driver\n}","preventionTips":["Guard getSchemas() by driver.","Use sqlsrv when schema listing is required.","Do not call in cross-driver utilities without a capability check."],"tags":["schema","database","driver-support","grammar","catalogue"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}