Repository navigation
refactor(connectors): split PEM and EXPLAIN code out of connector index files - #467
Merged
Merged
Conversation
…ex files Pure code moves, no behaviour change. postgres: the sslrootcert/sslcert/sslkey handling (PEM reading, encrypted key detection, and the pg.Client subclass that re-reads PEMs on every connection) moves from index.ts to ssl-pems.ts, alongside the existing failed-to-read-certificate.ts and type-parsers.ts helpers. sqlserver: the EXPLAIN emulation (SHOWPLAN_XML / STATISTICS XML on a dedicated single-connection pool, option prefix parsing, rollback wrapper and plan extraction) moves to explain.ts, taking the connector's config as a parameter instead of reading this.config. bindParameters and assertNoReadOnlyEscapes, shared by executeReadOnly and the explain paths, move to request-helpers.ts so both files import them from one place. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01T79tgGfqWNqUeTwhRc65MJ
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The extracted logic preserves existing behavior and remains covered by targeted connector tests.
0 open findings
What changed in this PR
Refactors PostgreSQL PEM handling and SQL Server EXPLAIN logic into focused modules without changing intended behavior.
Changes:
- Extracts PostgreSQL certificate loading and rotation helpers.
- Extracts SQL Server EXPLAIN emulation and shared request helpers.
- Strengthens SQL Server connection/configuration guarding.
| File | Description |
|---|---|
src/connectors/postgres/index.ts |
Uses extracted PEM utilities. |
src/connectors/postgres/ssl-pems.ts |
Houses PostgreSQL PEM handling. |
src/connectors/sqlserver/index.ts |
Delegates EXPLAIN and request operations. |
src/connectors/sqlserver/explain.ts |
Houses SQL Server EXPLAIN emulation. |
src/connectors/sqlserver/request-helpers.ts |
Centralizes parameter binding and read-only checks. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
3 of 4 tasks
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
Pure code moves out of the two largest connector files. No behaviour change.
sslrootcert/sslcert/sslkeyhandling (PEM reading, encrypted-key detection, SSL mode constants, and thepg.Clientsubclass that re-reads PEMs on every connection) moves fromindex.tstossl-pems.ts, alongside the existingfailed-to-read-certificate.tsandtype-parsers.tshelpers.explain.ts. The functions take the connector'ssql.configas a parameter instead of readingthis.config.bindParametersandassertNoReadOnlyEscapes, shared byexecuteReadOnlyand the explain paths, move torequest-helpers.tsso both files import them from one place.executeSQLguard in the SQL Server connector now checksconfigalongsideconnectioninstead of using a non-null assertion at the explain dispatch. Both are always set together inconnect.postgres/index.tssqlserver/index.tsTest plan
pnpm run buildsucceedspnpm test:unitpasses (1201 tests)tsc --noEmitoutput identical tomain(pre-existing errors only, none in touched files)🤖 Generated with Claude Code
https://claude.ai/code/session_01T79tgGfqWNqUeTwhRc65MJ
Generated by Claude Code