Skip to content

refactor(connectors): share MySQL/MariaDB schema introspection - #468

Merged
tianzhou merged 1 commit into
mainfrom
claude/bold-albattani-4fm1yh
Oct 9, 2026
Merged

tianzhou merged 1 commit into
mainfrom
claude/bold-albattani-4fm1yh

Conversation

@tianzhou

@tianzhou tianzhou commented Oct 9, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #467. The MySQL and MariaDB connectors carried near-identical copies of every INFORMATION_SCHEMA / SHOW CREATE method (getSchemas, getTables, getViews, tableExists, getTableIndexes, getTableSchema, getTableComment, getStoredProcedures, getStoredProcedureDetail, getDefaultSchema), differing only in the driver's result shape. Fixes could land in one and not the other.

  • New src/connectors/mysql-family-introspection.ts holds those methods as functions over a row-array query adapter, following the convention mysql-family-health-check.ts already uses.
  • Each connector keeps a small private requireQuery() that owns the "not connected" check and unwraps its driver's result shape (mysql2 resolves to [rows, fields]; mariadb to rows). The health check now goes through the same adapter.
  • Driver-specific code (DSN parsing, pooling, timeouts, executeSQL) stays in each connector's index.ts.

No behaviour change: the SQL, parameters, error messages and logging are unchanged, and the adapters call pool.query with the same arity as before (second argument omitted when there are no parameters).

File Before After
mysql/index.ts 807 423
mariadb/index.ts 747 363
mysql-family-introspection.ts new 419

Test plan

  • pnpm run build succeeds
  • pnpm test:unit passes (1201 tests)
  • tsc --noEmit clean in src/connectors/
  • CI integration suites for MySQL and MariaDB, which need Docker and could not run locally

🤖 Generated with Claude Code

https://claude.ai/code/session_01T79tgGfqWNqUeTwhRc65MJ


Generated by Claude Code

The MySQL and MariaDB connectors carried near-identical copies of every
INFORMATION_SCHEMA / SHOW CREATE method (getSchemas, getTables, getViews,
tableExists, getTableIndexes, getTableSchema, getTableComment,
getStoredProcedures, getStoredProcedureDetail, getDefaultSchema), differing
only in the driver's result shape. Fixes landed in one and not the other.

Move those into src/connectors/mysql-family-introspection.ts as functions
over a row-array query adapter, following the convention already used by
mysql-family-health-check.ts. Each connector keeps a small requireQuery()
that owns the "not connected" check and unwraps its driver's result shape
(mysql2 resolves to [rows, fields]; mariadb to rows). The driver-specific
parts (DSN parsing, pooling, timeouts, executeSQL) stay in each index.ts.

No behaviour change: the SQL, parameters, error messages and logging are
unchanged, and the adapter calls pool.query with the same arity as before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T79tgGfqWNqUeTwhRc65MJ
Copilot AI balanced review requested due to automatic review settings October 9, 2026 09:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The extraction preserves SQL, parameter handling, errors, and driver-specific result unwrapping without identified regressions.

0 open findings

What changed in this PR

Centralizes MySQL and MariaDB schema introspection while preserving connector-specific driver behavior.

Changes:

  • Extracts shared introspection functions.
  • Adds driver-specific row adapters.
  • Reuses adapters for health checks.
File Description
src/​connectors/​mysql/​index.ts Delegates introspection through the mysql2 adapter.
src/​connectors/​mariadb/​index.ts Delegates introspection through the MariaDB adapter.
src/​connectors/​mysql-family-introspection.ts Provides shared MySQL-family introspection logic.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tianzhou
tianzhou merged commit 06debe6 into main Oct 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants