Merged
Conversation
Member
|
Correction to the PR description: the claim under Implementation notes that Verification: the full |
Add a new async MySQL adapter using aiomysql (built on PyMySQL), complementing the existing asyncmy adapter. This gives teams with inherited aiomysql codebases a path to adopt sqlspec without a driver migration. Key implementation details: - Exception handling uses pymysql.err.* (aiomysql's underlying error hierarchy) - Connection.cursor() is synchronous (same as asyncmy, despite aiomysql docs) - Pool API uses aiomysql.create_pool() with "db" key (not "database" like asyncmy) - Parameter style: QMARK input -> POSITIONAL_PYFORMAT execution (identical to asyncmy) - Extensions (ADK, Litestar, Events) deferred to follow-up Refs: litestar-org#412 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- cursor() returns a Future on pool-acquired connections, must be awaited - Fix protocol to match (async cursor method) - Run ruff format on all new files to pass pre-commit validation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b734f68 to
77f3d12
Compare
AsyncmyConfig exposes AsyncmyPool so Litestar route handlers can type-hint the pool via DI. AiomysqlConfig omitted the analog, causing a silent parity gap. Add a runtime alias of aiomysql.Pool and register it in get_signature_namespace(), plus a unit test that locks the parity to prevent regression.
- Implemented AiomysqlStore for managing sessions with MySQL/MariaDB using aiomysql. - Added methods for session creation, retrieval, updating, and deletion with expiration handling. - Created integration tests for the AiomysqlStore, covering various scenarios including session management and expiration. - Introduced fixtures for setting up test databases with MySQL service. - Added tests for event handling with aiomysql, ensuring proper message publishing, acknowledgment, and redelivery.
sqlglot 30.6.0 changed how `exp.Update.where` renders: the generator now emits the node verbatim instead of prepending the "WHERE" keyword. Setting a bare condition expression on the "where" arg produced corrupted Oracle SQL like `UPDATE SET col = src.valsrc.val < t.val`, breaking test_oracle_merge_when_matched_with_condition after the sqlglot bump. Wrap the predicate in `exp.Where(this=...)` in both the builder fast-path and the Oracle normalizer so the generator emits `UPDATE SET ... WHERE <condition>` across dialects. Strengthen the unit test to assert the full Oracle render rather than just "UPDATE" substring.
aiomysql and asyncmy integration tests share the same MySQLService container and pytest-xdist group. Both test_features.py suites created identical unprefixed tables (json_test, isolation_test, bulk_test, error_test, advanced_test, concurrent_test, mysql_features) with CREATE TABLE IF NOT EXISTS plus unconditional inserts, so aiomysql data poisoned asyncmy primary keys and row counts when run sequentially. Rename aiomysql tables to match the _aiomysql convention already used by aiomysql_clean_driver so each adapter owns its own schema surface.
Mirror the asyncmy reference layout with an aiomysql section in docs/reference/adapters/mysql.rst covering AiomysqlConfig, AiomysqlDriver, AiomysqlConnectionParams, AiomysqlPoolParams, and AiomysqlDriverFeatures. Add an aiomysql row to the feature comparison table and update the MySQL card description in the adapters index so the adapter is discoverable from the landing grid.
DuckDB derives an attached-database name from the filename stem, so
repeated tests sharing the path test_sessions_<worker>.duckdb collide
process-wide when a prior connection has not released the file yet.
On CI this surfaced as a BinderException ("already attached by
database test_sessions_gw0") during test_sync_to_thread_concurrency.
Add a uuid4 suffix to the filename so each test owns its own attach
name, and explicitly close the config's connection pool in the
fixture teardown so the file handle is released before the next test
runs.
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
asyncmyadapter structure for consistencyCloses #412
Motivation
Teams with inherited
aiomysqlcodebases can adopt sqlspec without a driver migration. See #412 for full rationale.Implementation notes
Key differences from the
asyncmyadapter:asyncmy.errors.*pymysql.err.*(re-exported)"database""db"asyncmy.constants.FIELD_TYPEpymysql.constants.FIELD_TYPEasyncmy.create_pool()aiomysql.create_pool()Connection.cursor()is synchronous in both drivers (verified against aiomysql source — the docs are misleading).What's included
sqlspec/adapters/aiomysql/— full driver-only adapter (6 files, ~1,450 LOC)tests/unit/adapters/test_aiomysql/— unit tests (passing)tests/integration/adapters/aiomysql/— integration tests (need MySQL container in CI)pyproject.toml— optional dep, pytest marker, mypy ignoreWhat's NOT included (deferred)
SSCursorserver-side streaming supportTest plan
pytest tests/unit/adapters/test_aiomysql/ -v)pytest-databases)🤖 Generated with Claude Code