typeorm/typeorm · error · TypeORMError

Check schema queries are not supported by Spanner driver.

Error message

Check schema queries are not supported by Spanner driver.

What it means

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.

Source

Thrown at src/driver/spanner/SpannerQueryRunner.ts:516

    /**
     * Checks if schema with the given name exist.
     *
     * @param schema
     */
    async hasSchema(schema: string): Promise<boolean> {
        const result = await this.query(
            `SELECT * FROM "information_schema"."schemata" WHERE "schema_name" = @param0`,
            [schema],
        )
        return result.length ? true : false
    }

    /**
     * Loads currently using database schema
     */
    async getCurrentSchema(): Promise<string> {
        throw new TypeORMError(
            `Check schema queries are not supported by Spanner driver.`,
        )
    }

    /**
     * Checks if table with the given name exist in the database.
     *
     * @param tableOrName
     */
    async hasTable(tableOrName: Table | string): Promise<boolean> {
        const tableName =
            tableOrName instanceof Table ? tableOrName.name : tableOrName
        const sql =
            `SELECT * FROM \`INFORMATION_SCHEMA\`.\`TABLES\` ` +
            `WHERE \`TABLE_CATALOG\` = '' AND \`TABLE_SCHEMA\` = '' AND \`TABLE_TYPE\` = 'BASE TABLE' ` +
            `AND \`TABLE_NAME\` = @param0`
        const result = await this.query(sql, [tableName])
        return result.length ? true : false

View on GitHub (pinned to 04ff4daedc)

Solutions

  1. Drop the getCurrentSchema() call; Spanner collapses schema into the database.
  2. If you need a logical schema label, derive it from your own config rather than the runner.

Example fix

// before
const schema = await qr.getCurrentSchema();

// after
// Spanner has no separate schema; do not call this method.
Defensive patterns

Strategy: try-catch

Validate before calling

// Spanner has no separate schema; skip this call entirely.
function currentSchema(_ds: DataSource): string | undefined {
  return undefined;
}

Type guard

function supportsGetCurrentSchema(ds: DataSource): boolean {
  return (ds.options as any).type !== "spanner";
}

Try / catch

try {
  await qr.getCurrentSchema();
} catch (e) {
  if (/not supported by Spanner/i.test(String(e?.message ?? e))) return undefined;
  throw e;
}

Prevention

When it happens

Trigger: Calling queryRunner.getCurrentSchema(); framework helpers that log/branch on the active schema.

Common situations: Ported introspection code from drivers with separate schema namespaces (Postgres, SQL Server).

Related errors


AI-assisted analysis of typeorm/typeorm@04ff4daedc (2026-08-03). Data as JSON: /data/errors/5139ace864cbd2c2.json. Report an issue: GitHub.