Repository navigation
Conversation
SQLAlchemy 2.1 made ScalarAttributeImpl and register_attribute private (_ScalarAttributeImpl, _register_attribute), breaking import of sqlalchemy_utils. Import the new names with a fallback for 2.0. Also make the version check tolerate pre-release versions (e.g. 2.1.0b1), and pin the test PostgreSQL DSN to psycopg2 since 2.1 changed the default postgresql:// driver to psycopg (v3).
Collaborator
|
sqlalchemy is explicitly discouraging this usage. Changing sqlalchemy-utils to support this usage doesn't align with what upstream is explicitly trying to accomplish. I'm open to a solution that doesn't rely on sqlalchemy internals like this, though! |
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
import sqlalchemy_utilsfails on SQLAlchemy 2.1:SQLAlchemy 2.1 made several attribute internals private. This PR:
_ScalarAttributeImpl/_register_attributeon 2.1+, falling back toScalarAttributeImpl/register_attributeon 2.0 (used bygeneric_relationship).GenericAttributeImpltolerate pre-release version strings (e.g.2.1.0b1), which previously raisedValueError.postgresql+psycopg2://. SQLAlchemy 2.1 changed the defaultpostgresql://driver to psycopg (v3), whichCompositeTypedoesn't support; this keeps the tests using the same driver as before.Testing
Full suite run locally against PostgreSQL and MySQL on both SQLAlchemy 2.1.0 and 2.0.54: 2690 passed on each, with identical results. The one failure on both is the psycopg2cffi test, because that driver isn't installed locally. MSSQL was not tested locally.
Notes
CompositeTypestill only supports psycopg2. On SQLAlchemy 2.1, users with a plainpostgresql://URL now get psycopg3 and aTypeErroraboutcursor_factory. They needpostgresql+psycopg2://for now. psycopg3 support could come in a follow-up.