{"id":"5139ace864cbd2c2","repo":"typeorm/typeorm","slug":"check-schema-queries-are-not-supported-by-spanner","errorCode":null,"errorMessage":"Check schema queries are not supported by Spanner driver.","messagePattern":"Check schema queries are not supported by Spanner driver\\.","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"src/driver/spanner/SpannerQueryRunner.ts","lineNumber":516,"sourceCode":"\n    /**\n     * Checks if schema with the given name exist.\n     *\n     * @param schema\n     */\n    async hasSchema(schema: string): Promise<boolean> {\n        const result = await this.query(\n            `SELECT * FROM \"information_schema\".\"schemata\" WHERE \"schema_name\" = @param0`,\n            [schema],\n        )\n        return result.length ? true : false\n    }\n\n    /**\n     * Loads currently using database schema\n     */\n    async getCurrentSchema(): Promise<string> {\n        throw new TypeORMError(\n            `Check schema queries are not supported by Spanner driver.`,\n        )\n    }\n\n    /**\n     * Checks if table with the given name exist in the database.\n     *\n     * @param tableOrName\n     */\n    async hasTable(tableOrName: Table | string): Promise<boolean> {\n        const tableName =\n            tableOrName instanceof Table ? tableOrName.name : tableOrName\n        const sql =\n            `SELECT * FROM \\`INFORMATION_SCHEMA\\`.\\`TABLES\\` ` +\n            `WHERE \\`TABLE_CATALOG\\` = '' AND \\`TABLE_SCHEMA\\` = '' AND \\`TABLE_TYPE\\` = 'BASE TABLE' ` +\n            `AND \\`TABLE_NAME\\` = @param0`\n        const result = await this.query(sql, [tableName])\n        return result.length ? true : false","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/typeorm/typeorm/blob/04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96/src/driver/spanner/SpannerQueryRunner.ts#L498-L534","documentation":"TypeORMError thrown unconditionally by getCurrentSchema(). Spanner has no schema concept distinct from the database, so there is no current schema to return; the runner refuses rather than returning a misleading value.","triggerScenarios":"Calling queryRunner.getCurrentSchema(); framework helpers that log/branch on the active schema.","commonSituations":"Ported introspection code from drivers with separate schema namespaces (Postgres, SQL Server).","solutions":["Drop the getCurrentSchema() call; Spanner collapses schema into the database.","If you need a logical schema label, derive it from your own config rather than the runner."],"exampleFix":"// before\nconst schema = await qr.getCurrentSchema();\n\n// after\n// Spanner has no separate schema; do not call this method.","handlingStrategy":"try-catch","validationCode":"// Spanner has no separate schema; skip this call entirely.\nfunction currentSchema(_ds: DataSource): string | undefined {\n  return undefined;\n}","typeGuard":"function supportsGetCurrentSchema(ds: DataSource): boolean {\n  return (ds.options as any).type !== \"spanner\";\n}","tryCatchPattern":"try {\n  await qr.getCurrentSchema();\n} catch (e) {\n  if (/not supported by Spanner/i.test(String(e?.message ?? e))) return undefined;\n  throw e;\n}","preventionTips":["Do not call getCurrentSchema on Spanner runners.","Remove schema-introspection helpers when porting to Spanner.","Treat schema and database as the same concept on Spanner."],"tags":["spanner","schema","unsupported","metadata"],"analyzedSha":"04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96","analyzedAt":"2026-08-03T18:27:32.281Z","schemaVersion":2}