Repository navigation
refactor(connectors): share MySQL/MariaDB schema introspection - #468
Merged
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
🟢 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.src/connectors/mysql-family-introspection.tsholds those methods as functions over a row-array query adapter, following the conventionmysql-family-health-check.tsalready uses.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.executeSQL) stays in each connector'sindex.ts.No behaviour change: the SQL, parameters, error messages and logging are unchanged, and the adapters call
pool.querywith the same arity as before (second argument omitted when there are no parameters).mysql/index.tsmariadb/index.tsmysql-family-introspection.tsTest plan
pnpm run buildsucceedspnpm test:unitpasses (1201 tests)tsc --noEmitclean insrc/connectors/🤖 Generated with Claude Code
https://claude.ai/code/session_01T79tgGfqWNqUeTwhRc65MJ
Generated by Claude Code