Skip to content

fix: handle engine objects in quote func for SQLAlchemy 2 compatibility#677

Closed
introvenk wants to merge 1 commit into
kvesteri:masterfrom
introvenk:master
Closed

fix: handle engine objects in quote func for SQLAlchemy 2 compatibility#677
introvenk wants to merge 1 commit into
kvesteri:masterfrom
introvenk:master

Conversation

@introvenk
Copy link
Copy Markdown

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

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
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
@christopherpickering
Copy link
Copy Markdown

It would be cool to release this :)

@fdiaz3000
Copy link
Copy Markdown

I am waiting for this release as well since I am migrating to sqlalchemy 2.0. thank you :)

@juancotrino
Copy link
Copy Markdown

Yes, please review this and release it.

@kvesteri
Copy link
Copy Markdown
Owner

Fixed in #690

@kvesteri kvesteri closed this Feb 11, 2023
@nickjj
Copy link
Copy Markdown

nickjj commented Feb 16, 2023

@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:
image

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.

@kvesteri
Copy link
Copy Markdown
Owner

I added the tag 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incompatibility of create_database() from sqlalchemy-utils 0.39.0 with SQLAlchemy 2.0.0

7 participants