-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for sqlalchemy 2 #77
Add support for sqlalchemy 2 #77
Conversation
631a609
to
790946a
Compare
Thanks for your effort! |
790946a
to
ae5c2ae
Compare
I've merged #78 to master, rebased this branch on master and squashed a bunch of commits. |
- Updated result coercion logic to support sqlalchemy2 - Modified tests to use future=True and sqlalchemy2 style, including the following fixes: - Fix "The ``declarative_base()`` function is now available as sqlalchemy.orm.declarative_base()" - Fix "The legacy calling style of select() is deprecated and will be removed in SQLAlchemy 2.0. Please use the new calling style described at select()" - Fix "This Session located a target engine via bound metadata; as this functionality will be removed in SQLAlchemy 2.0, an Engine object should be passed to the Session() constructor directly" - Fix "The legacy calling style of select() is deprecated and will be removed in SQLAlchemy 2.0. Please use the new calling style described at select()" - Fix "RemovedIn20Warning: The Query.from_self() method is considered legacy as of the 1.x series of SQLAlchemy and will be removed in 2.0. The new approach is to use the orm.aliased() construct in conjunction with a subquery."
3ff3c2e
to
e7b3192
Compare
That's really great :) Thank you for following up on this :)
Yes, that was the reason. Great that it can be simplified 👍 |
f3ba0eb
to
e2f6215
Compare
e2f6215
to
ca18b60
Compare
- Use Python 3.7 (our new minimum supported version) - Test with SQLAlchemy 2.0 - Use large resource class for more CPU cores - Use pytest-xdist to run tests on 4 cores
ca18b60
to
2d89bf5
Compare
As you can see I left the sqla14/sqla20 split more or less as you had it, just reorganized the files a little and made all imports explicit. Tests are passing with all sqlalchemy versions so I think we're good to go. I'm working on some additional stuff (type hints, asyncio support) on another branch but I'm going to go ahead and release this chunk now. Thanks again for your contribution! |
Awesome 🎉 |
Wow - amazing effort! |
Great job, thank you |
This PR adds support for sqlalchemy 2.
I followed the docs for migrating to version 2:
First I made my local environment ready by being able to run the tests (I used only sqlite).
poetry
(I also tried to make a PR for that but it always failed in ci and I couldn't figure out the reason yet...). I also had to change the syntax of thetoml
file for github dependencies and bump the python version to >=3.7.Then I turned on RemovedIn20Warnings and fixed those warnings (here is a list):
declarative_base()
function is now available as sqlalchemy.orm.declarative_base(). (deprecated since: 1.4) (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)I added
future=True
to engine and sessionmaker. This was only in tests.Finally I upgraded to sqlachemy 2.
@djrobstep I think I need your help here. I don't seem to be able to upgrade poetry. I tried also in a separate PR but did not manage. The output of
poetry install
does not show me any errors but the step fails in ci. Locally I have everything working fine 🤔 I did try a lot of ideas but nothing helped me understand why install fails. Can you help me? I think it would be great ifsqlakeyset
support sqlalchemy 2.0 :) Thanks!Update 1: I suspect an out of memory error in circleci 🤔
Update 2: the problem was python-poetry/poetry#7184 and was solved by passing --no-ansi to the poetry install command.
Note: we might need to change the tests if we want to support sqlalchemy < 1.4