-
Notifications
You must be signed in to change notification settings - Fork 132
chore: de-flak mysql/mariadb test #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modifies the MySQL and MariaDB connectors to use dedicated connections from the pool for SQL execution, ensuring session consistency for session-specific features like LAST_INSERT_ID(). Previously, using pool.query() directly could result in different connections being used for consecutive queries, breaking session-dependent functionality.
Key changes:
- Acquires a dedicated connection via
pool.getConnection()before executing queries - Ensures connection is properly released back to the pool in a
finallyblock - Updates comments to reflect the use of dedicated connections instead of pool-level queries
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/connectors/mysql/index.ts | Modified executeSQL to use dedicated connections with proper cleanup, also removed trailing whitespace |
| src/connectors/mariadb/index.ts | Modified executeSQL to use dedicated connections with proper cleanup, also removed trailing whitespace |
Fixed session consistency issues causing intermittent test failures with LAST_INSERT_ID(). The root causes were: 1. Separate executeSQL() calls getting different connections from pool 2. Multi-statement results including metadata objects from INSERT/UPDATE/DELETE Changes: - Updated connectors to use explicit connection acquisition (pool.getConnection) - Enhanced multi-statement result handling to filter out metadata objects - Modified tests to combine INSERT and SELECT into single executeSQL call - Ensures all SQL in one call uses same connection for session-specific features Tests now pass consistently (32/32 MariaDB, 30/30 MySQL verified across multiple runs). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
…detection Replaced the fragile `constructor.name === 'ResultSetHeader'` check with robust property-based type detection using specific properties like 'affectedRows', 'insertId', and 'fieldCount'. This prevents potential breakage from minification or bundling tools that can mangle constructor names. The new approach: - Checks for ResultSetHeader-specific properties instead of constructor name - More resilient to code transformations - Maintains the same functionality and test coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Created a shared utility to handle multi-statement SQL result parsing, eliminating code duplication between MariaDB and MySQL connectors. The new utility provides: - Consistent detection of metadata objects vs row arrays - Unified handling of single and multi-statement results - Property-based type checking (no fragile constructor.name checks) - Clear, well-documented logic for both driver behaviors Changes: - Added src/utils/multi-statement-result-parser.ts with shared parsing logic - Updated MariaDB connector to use parseQueryResults() - Updated MySQL connector to use parseQueryResults() - Reduced duplicated code by 70 lines while adding 93 lines of reusable utility Benefits: - Single source of truth for result parsing logic - Easier to maintain and test - More resilient to driver API changes - Consistent behavior across both connectors All tests pass (32 MariaDB + 30 MySQL = 62 tests). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
No description provided.