Skip to content
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

✨ Upgrade SQLAlchemy to 2.0, including initial work by farahats9 #700

Merged
merged 43 commits into from
Nov 18, 2023

Conversation

tiangolo
Copy link
Member

@tiangolo tiangolo commented Nov 18, 2023

✨ Upgrade SQLAlchemy to 2.0, including initial work by @farahats9

This includes @farahats9 commits from #563 and builds on top.

  • I reverted a few things, e.g. altering the docs to workaround for a previous lack of support for forward references.
  • Added support/fix for forward reference errors.
  • Removed several sections/modules that are no longer necessary, as were mainly to add type annotations to SQLAlchemy things, but now with SQLAlchemy's new proper types that's no longer necessary and I can reuse SQLAlchemy's things directly.
  • Updated all needed tests, e.g. to support the latest FastAPI.
  • Updated all the generated selects to use the new SQLAlchemy types.
  • Updated the classes and type annotations with the new SQLAlchemy types, with some overloads to make sure they are compatible with SQLModel. E.g. select().where().
  • Redefine all functions that would take column operations to accept the types used by SQLModel, e.g. or_(Hero.name == "Deadpond") as SQLAlchemy's version would require Hero.name to be a Mapped[str] instead of a str.
  • I explored a lot if it was possible/sensible to use and encourage the new Mapped[X], but sadly that breaks type annotations for creating new instances and dataclass_transform, as then that would expect to receive values with Mapped[X], e.g. Mapped[str] instead of str. And it would also add complications to the Pydantic handling. So, this was a lot of work mostly exploratory, but not much ended in the PR.

farahats9 and others added 30 commits March 7, 2023 02:08
Copy link

📝 Docs preview for commit 80a5c52 at: https://77c66c1a.sqlmodel.pages.dev

Copy link

📝 Docs preview for commit 40beca9 at: https://b1ab6983.sqlmodel.pages.dev

Copy link

📝 Docs preview for commit be5277e at: https://0db51043.sqlmodel.pages.dev

@tiangolo tiangolo marked this pull request as ready for review November 18, 2023 11:29
@tiangolo tiangolo added the feature New feature or request label Nov 18, 2023
@tiangolo tiangolo changed the title ✨ Upgrade SQLAlchemy to 2.0, including initial work by @farahats9 ✨ Upgrade SQLAlchemy to 2.0, including initial work by farahats9 Nov 18, 2023
@tiangolo tiangolo merged commit 8ed856d into main Nov 18, 2023
12 checks passed
@tiangolo tiangolo deleted the sa2-a branch November 18, 2023 11:30
@tiangolo tiangolo mentioned this pull request Nov 20, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants