zopefoundation / zope.sqlalchemy

Integration of SQLAlchemy with transaction management
Other
32 stars 34 forks source link

Add support for SQLAlchemy 2.x #76

Closed icemac closed 1 year ago

icemac commented 1 year ago

Currently tests fail when running against 2.x, so we have to pin SQLAlchemy to < 2 for now.

See #64 as preparation for this issue.

hoonhout commented 1 year ago

@icemac I forked this repo to test if our application landscape is compatible with SQLA 2.0. It appears that I now have a draft PR ready that makes the tests for this package compatible with SQLA 2.0 as described in #64. It currently resides in our fork (https://github.com/VanOord/zope.sqlalchemy/pull/1), but I'm happy to make a proper PR if interested.

icemac commented 1 year ago

@hoonhout A PR for SQLAlchemy 2 compatibility would be very helpful.

Please notice beforehand: According to the contributing policies of the zopefoundation organization you need to sign a contributor agreement before any non-trivial change can be merged. For details please consult the Contributing guidelines for zopefoundation projects.

olemoign commented 1 year ago

This issue is preventing my company from migrating to SQLAlchemy 2.x, is there anything I can do to help?

icemac commented 1 year ago

@hoonhout As you have already created a draft PR, is there a way to help to get it into the main repository?

bouillon commented 1 year ago

It would be nice somebody can upgrade the package on pypi we need it to get the possibility to migrate to sqlalchemy 2

icemac commented 1 year ago

@bouillon Creating a release is not enough, at first the package has to be ported to support SQLAlchemy >= 2 (e. g. see the warnings presented in #64). Any help is appreciated.

Daverball commented 1 year ago

I created a PR: https://github.com/zopefoundation/zope.sqlalchemy/pull/79

There's really not much that needed to be changed.

bouillon commented 1 year ago

Something blocks from merge?

Daverball commented 1 year ago

The issues on the CI have been ironed out, so for now I am just waiting on a review, which will happen when it will happen. You can install version 1.6 with SQLAlchemy 2.0 in the meantime, it didn't have the pin to prevent it from being installed along with SQLAlchemy 2.0 yet. I already have it running that way on multiple projects in production without issue.

There were no code changes necessary in the actual production code, it's just the tests that needed to be updated. (Although if you want to switch to the new psycopg v3 backend in SQLAlchemy that won't work properly with 1.6, since the transaction will not be retried on serialization errors, I added support for that as part of my pull request as well, since we would like to switch to that)

bouillon commented 1 year ago

Thanks for reply. Yeas I run it also like you say on some projects. For some other I need an official package on pypi. Let's wait than.

Daverball commented 1 year ago

zope.sqlalchemy 1.6 is still available on pypi, so if you pin that to 1.6, then installing SQLAlchemy >2 will work. zope.sqlalchemy 2.0 added the SQLAlchemy <2 version pin but other than that only really made minor changes (dropping support for older Python versions and making some cosmetic improvement afforded by the higher minimum version, semantically nothing has changed between 1.6 and 2.0). 1.6. also works perfectly fine with Python 3.10 and 3.11, it just wasn't explicitly tested on the CI.

bouillon commented 1 year ago

thanks for this explanations

icemac commented 1 year ago

Fixed in #79. I just released https://pypi.org/project/zope.sqlalchemy/3.0/ containing this fix.