feat: full SQLAlchemy 2.0 support with 1.4 backward compat#36
Open
feat: full SQLAlchemy 2.0 support with 1.4 backward compat#36
Conversation
aa2ba71 to
52ba319
Compare
- Add import_dbapi() classmethod alongside dbapi() (fixes #9, #31) - Version-conditional create_engine params (future/implicit_returning only passed on SA <2.0) - Fix inspector to use connection-based execution (Engine.execute() removed in SA 2.0) - Declare runtime dependencies in pyproject.toml - Remove SQLAlchemy <2 cap from test dependencies - Add Python 3.12/3.13 classifiers, bump version to 1.2.0 - Update Dockerfile from EOL buster to bookworm, Python 3.13 - Add SA 2.0 compatibility test suite Closes #9, closes #31 Refs #35 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
52ba319 to
e035df0
Compare
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
SQLAlchemy 2.0 compatibility while maintaining backward compat with SA 1.4. Bumps version to 1.2.0.
Dialect (
dialect.py)import_dbapi()classmethod alongsidedbapi()(fixes SADeprecationWarning - Implement an import_dbapi() #9, SQLAlchemy SADeprecationWarning #31, supersedes Fix SADeprecationWarning #33)create_engineparams —futureandimplicit_returningonly passed on SA <2.0 (removed in 2.0)packaging.version.VersionInspector (
inspector.py)Engine.execute()is removed in SA 2.0 — allself.bind.execute()calls now go through a_get_connection()helper that opens a connection from the engine when needed, with proper cleanupPackaging (
pyproject.toml)SQLAlchemy>=1.4,psycopg2-binary>=2.9,packagingSQLAlchemy<2cap from test dependenciesDocker (
Dockerfile,Makefile)python:3.13-slim-bookwormRUNlayers, remove staleSQLALCHEMY_SILENCE_UBER_WARNINGpip install .now picks up declared runtime depsTests (
test_sa2_compat.py)import_dbapi()returns the moduledbapi()still works (backward compat)create_engine/create_superset_engineproduce no deprecation warningsSA_V2flag matches installed SA versionBackward compatibility
On SA 1.4 (as used by Superset 4.x/5.x which pins
sqlalchemy>=1.4, <2), every code path produces identical behavior to the original:SA_V2 = False→future=andimplicit_returning=are passed as beforeimport_dbapi()exists but SA 1.4 callsdbapi()— both work_get_connection()callsEngine.connect()which works on both SA versionsTest plan
ruff checkcleanCloses #9, closes #31
Refs #35
🤖 Generated with Claude Code