Skip to content

Relax sqlalchemy version pin and add pre-release test workflow#1884

Closed
mscheltienne wants to merge 2 commits into
fastapi:mainfrom
mscheltienne:rm_pin
Closed

Relax sqlalchemy version pin and add pre-release test workflow#1884
mscheltienne wants to merge 2 commits into
fastapi:mainfrom
mscheltienne:rm_pin

Conversation

@mscheltienne

Copy link
Copy Markdown

At my company, we are driving towards compatibility with python 3.14t free-threaded. While investigating the remaining changes necessary, we noticed that:

  • Our CIs are happy with sqlalchemy version 2.1.0b2 + sqlmodel 0.0.38 (everything pass, we test mainly DB operations with postgres using psycopg[c] against local dockerized DB and against actual AWS DB).
  • The test environment was tricky to build because sqlmodel 0.0.38 (and other versions) have a very conservative "SQLAlchemy >=2.0.14,<2.1.0" constraint, preventing the installation of 2.1.0b2 by default.
  • As far as I could tell, sqlmodel seems compatible with SQLAlchemy 2.1.0+

This PR thus proposes 2 changes:

  1. Relax the constraint to <2.2.0, offering support for the new SQLAlchemy version soon-to-be-released and by extension to free-threaded python.
  2. Add a test job which runs against the latest release of sqlalchemy, including pre-release versions.

@mscheltienne

mscheltienne commented Apr 23, 2026

Copy link
Copy Markdown
Author

Should I run uv lock --upgrade? What is your workflow here? For now I ran it without the --upgrade flag.

@github-actions

Copy link
Copy Markdown
Contributor

📝 Docs preview

Last commit 175f9db at: https://6588ea3c.sqlmodel.pages.dev

@YuriiMotov

Copy link
Copy Markdown
Member

I think until SQLAlchemy 2.1 released, they can still break things. So, it's not correct to relax the pin now.
Let's wait for the release

@YuriiMotov YuriiMotov closed this Jul 15, 2026
Comment thread pyproject.toml
]

dependencies = [
"SQLAlchemy >=2.0.14,<2.1.0",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could keep this PR open with "SQLAlchemy>=2.1.0", removing the upper pin and keeping the pre-release job. But that would have to get merged after 2.1.0 is out.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But will we need this after 2.1.0 is out? We will just test if it works and bump the pin

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was proposing to remove the upper pin so that 2.2 would not be unsupported when it releases; and to keep the job testing actively against the main branch to catch any API change / failure early instead of after the release of a new version of that core dependency.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I got it)

I still think it brings more risks than benefits..
If you urgently need to use latest SQLAlchemy in your project, what if you override the dependency pin for SQLAlchemy in your project?

With uv you can add the following to your pyproject.toml:

[tool.uv]
override-dependencies = [
    "sqlalchemy==2.1.0b3",
]

Then, uv pip list returns:

sqlalchemy        2.1.0b3
sqlmodel          0.0.39

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh we haven't waited ahah We have been using sqlalchemy==2.1.0b2 for the past couple of months, no issues.

My comment is more focused on the future maintenance of this project: if you have a job which continuously test against the new version of sqlalchemy (main); you can catch issues and incompatibilities early rather than having to wait for a release of sqlalchemy to then test and fix everything that is broken.

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.

3 participants