Upgrade SQLAlchemy from v1 to v2 for Python 3.14 support#3290
Closed
MaxGhenis wants to merge 1 commit intoPolicyEngine:masterfrom
Closed
Upgrade SQLAlchemy from v1 to v2 for Python 3.14 support#3290MaxGhenis wants to merge 1 commit intoPolicyEngine:masterfrom
MaxGhenis wants to merge 1 commit intoPolicyEngine:masterfrom
Conversation
SQLAlchemy v1 does not support Python 3.14, making this upgrade a blocker. Key changes: - Update setup.py pin from sqlalchemy>=1.4,<2 to sqlalchemy>=2,<3 - Replace removed engine.execute() with connection-based execution using conn.exec_driver_sql() inside a connection context manager - Add _ResultProxy wrapper to eagerly fetch results so they survive connection closure (maintains existing fetchone()/fetchall() API) - Replace LegacyRow (removed in v2) with Row in type annotations - Update test mocks that used spec=LegacyRow to use plain MagicMock() since Row in v2 has a different interface - Add 10 dedicated SQLAlchemy v2 compatibility tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
562207c to
8cad222
Compare
Collaborator
Author
|
Recreating from org branch so CI has access to secrets. |
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
>=1.4,<2to>=2,<3to unblock Python 3.14 support (SQLAlchemy v1 does not support Python 3.14)engine.execute()with connection-based execution (conn.exec_driver_sql()) inside a context manager, with explicitconn.commit()_ResultProxywrapper that eagerly fetches results within the connection context so they survive connection closure, maintaining the existingfetchone()/fetchall()API contractLegacyRow(removed in v2) withRowin type annotations across all service filesspec=LegacyRowto use plainMagicMock()sinceRowin v2 has a different interface (no.keys()method)_ResultProxy,_execute_remote, and the version requirementTest plan
tests/unit+tests/to_refactor)_ResultProxywrapper correctly handles SELECT, INSERT, UPDATE, DELETE via the newtest_sqlalchemy_v2.pytests🤖 Generated with Claude Code