fix: handle engine objects in quote func for SQLAlchemy 2 compatibility#677
Closed
introvenk wants to merge 1 commit into
Closed
fix: handle engine objects in quote func for SQLAlchemy 2 compatibility#677introvenk wants to merge 1 commit into
introvenk wants to merge 1 commit into
Conversation
With SQLAlchemy 2.0 and postgres, 'create_database()'' function from sqlalchemy-utils was failing and the issue was caused by the failure of the quote() function to determine the dialect of the database driver. This was due to the removal of the direct engine.execute() calls in SQLAlchemy 2.0 which caused the get_bind() function to fail in case of Engine object. This change adds a check in the quote() function to see if the input is an engine object. If it is, the dialect attribute is used directly instead of trying to use the get_bind() function. This resolves the issue with create_database() where the get_bind() function was not able to return a bind for the engine object and the subsequent failure of the quote() function. This change allows the 'create_database()'' function from the sqlalchemy-utils library to be compatible with SQLAlchemy 2.0.0 Fixes kvesteri#676
23 tasks
nickjj
added a commit
to nickjj/docker-flask-example
that referenced
this pull request
Feb 3, 2023
There's an incompatibility with creating new databases when it comes to using sqlalchemy-utils with sqlalchemy 2.0. We can't upgrade until this PR gets merged and a new version of sqlalchemy-utils is available: kvesteri/sqlalchemy-utils#677
hyperleex
approved these changes
Feb 6, 2023
|
It would be cool to release this :) |
|
I am waiting for this release as well since I am migrating to sqlalchemy 2.0. thank you :) |
|
Yes, please review this and release it. |
Owner
|
Fixed in #690 |
|
@kvesteri, I see 0.40.0 is available on PyPi and the changelog is updated but there's no tag / release on GitHub. At the time of making this comment, this is the latest release: I know we can install 0.40.0 through PyPi and everything is good to go but thought I'd throw this out there in case you want to keep your release page in sync with what's really released. |
Owner
|
I added the tag 👍 |
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.

With SQLAlchemy 2.0 and postgres, 'create_database()'' function from sqlalchemy-utils was failing and the issue was caused by the failure of the quote() function to determine the dialect of the database driver. This was due to the removal of the direct engine.execute() calls in SQLAlchemy 2.0 which caused the get_bind() function to fail in case of Engine object.
This change adds a check in the quote() function to see if the input is an engine object. If it is, the dialect attribute is used directly instead of trying to use the get_bind() function.
This resolves the issue with create_database()
where the get_bind() function was not able to return a bind for the engine object and the subsequent failure of the quote() function.
This change allows the 'create_database()'' function from the sqlalchemy-utils library to be compatible with SQLAlchemy 2.0.0
Fixes #676