windmill-labs/windmill · error

Unsupported database type: ${dbType}

Error message

Unsupported database type: ${dbType}

What it means

makeForeignKeysQuery generates the catalog query used to list foreign keys for a table, with a dedicated variant per supported database (including information_schema queries for postgres/mysql, and specific helpers for snowflake, bigquery, duckdb). The default branch throws with the offending dbType when no variant exists. BigQuery genuinely lacks foreign-key metadata, so unsupported types are rejected rather than producing broken SQL.

Source

Thrown at frontend/src/lib/components/apps/components/display/dbtable/queries/relationalKeys.ts:56

	const tableParts = table.split('.')
	const tableName = tableParts[tableParts.length - 1]
	const schemaName = tableParts.length > 1 ? tableParts[0] : defaultSchema

	switch (dbType) {
		case 'postgresql':
			return makePostgresForeignKeysQuery(tableName, schemaName || 'public')
		case 'mysql':
			return makeMysqlForeignKeysQuery(tableName, schemaName || '')
		case 'ms_sql_server':
			return makeMsSqlForeignKeysQuery(tableName, schemaName || 'dbo')
		case 'snowflake':
			return makeSnowflakeForeignKeysQuery(tableName, schemaName || 'PUBLIC')
		case 'bigquery':
			return makeBigQueryForeignKeysQuery(tableName, schemaName)
		case 'duckdb':
			return makeDuckDbForeignKeysQuery(tableName, schemaName || 'main')
		default:
			throw new Error(`Unsupported database type: ${dbType}`)
	}
}

/**
 * Generates SQL query to fetch primary key constraint name for a specific table
 * @param dbType - The database type
 * @param table - The table name (can include schema, e.g., "schema.table")
 * @param defaultSchema - The default schema to use when table doesn't include one
 * @returns SQL query string
 */
export function makePrimaryKeyConstraintQuery(
	dbType: DbType,
	table: string,
	defaultSchema?: string
): string {
	const tableParts = table.split('.')
	const tableName = tableParts[tableParts.length - 1]
	const schemaName = tableParts.length > 1 ? tableParts[0] : defaultSchema

View on GitHub (pinned to e474e8803c)

Solutions

  1. Check the resource's resourceType and use a supported database for schema exploration.
  2. Normalize ducklake to 'duckdb' before the call.
  3. Add a make<Db>ForeignKeysQuery case if the new database exposes FK metadata.
  4. Hide/disable the FK panel for unsupported dbTypes in the UI instead of calling the builder.

Example fix

// before
const q = makeForeignKeysQuery(dbType, table, schema)
// after
const SUPPORTED_FK = ['mysql','postgresql','ms_sql_server','snowflake','bigquery','duckdb']
if (!SUPPORTED_FK.includes(dbType)) return null // render 'relations unsupported' state
const q = makeForeignKeysQuery(dbType, table, schema)
Defensive patterns

Strategy: validation

Validate before calling

const FK_SUPPORTED = ['mysql','postgresql','ms_sql_server','snowflake','bigquery','duckdb']
const dbType = dbInput.type === 'ducklake' ? 'duckdb' : dbInput.resourceType
if (!FK_SUPPORTED.includes(dbType)) {
  return null // render 'relations not available' instead of querying
}

Type guard

const supportsForeignKeys = (t: unknown): t is DbType =>
  typeof t === 'string' && ['mysql','postgresql','ms_sql_server','snowflake','bigquery','duckdb'].includes(t)

Try / catch

try {
  const q = makeForeignKeysQuery(dbType, table, schema)
} catch (e) {
  if (String(e?.message).startsWith('Unsupported database type')) {
    setRelationsUnavailable(true)
    return
  }
  throw e
}

Prevention

When it happens

Trigger: Calling fkQuery/makeForeignKeysQuery with a dbType outside the switch (mysql, postgresql, ms_sql_server, snowflake, bigquery, duckdb, …) — e.g. an exotic resource type, an unmapped alias, or a type added after this builder was written.

Common situations: Opening the relations/foreign-keys panel of the dbtable against an unsupported database resource; resourceType typo in app config; new integration not yet supported by the relational-keys feature.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/451017333a026a73. Report an issue: GitHub.