Skip to content

Upgrade to support SQLAlchemy 2.x #205

Open

Description

@VickyTwig
  • liminal-orm pins sqlalchemy<2 (specifically 1.4.49)
  • We have a dependency on sqlalchemy[asyncio]>=2.0.0: one of our packages declares fastapi-users[sqlalchemy]>=13.0.0,<14, which pulls fastapi-users-db-sqlalchemy 7.0.0, which hard-requires sqlalchemy[asyncio]>=2.0.0,<2.1.0. Auth/OAuth machinery mandates SQLAlchemy 2.x.
  • Downgrading the package to SQLAlchemy 1.x would require also downgrading fastapi-users to ~10.x/11.x — a multi-major-version backstep of the auth library, with API changes around password hashing (pwdlib) and strategy interfaces.
  • (Claude reassures me that) SQLAlchemy 1.4 → 2.0 is mostly mechanical for declarative-base usage like liminal's

Would it be possible to upgrade sqlalchemy to support SQLAlchemy 2.x?

Many thanks!

Vicky

Activity

  1. VickyTwig commented on Apr 29, 2026

    @VickyTwig
    Author

    PS we've found a way around this so it's more of a nice to have for the future so low priority :)

  2. nirmit-damania-dyno commented on May 4, 2026

    @nirmit-damania-dyno
    Contributor

    Hey Vicky!

    This is definitely on my radar, but currently blocked by my company (Dyno Tx) still being on SQLAlchemy 1.

    I'm curious to learn about your work around, to share knowledge in case others are facing a similar issue!

  3. xravitycapital commented on Nov 11, 2026

    @xravitycapital

    Hi Nirmit! I saw you mentioned this is blocked because Dyno is still on SQLAlchemy 1.x. I looked into whether liminal could support both 1.4 and 2.0, so nobody is forced to upgrade, and it turned out to be a small change:

    • widen the pin to sqlalchemy>=1.4.53,<2.1 (1.4 stays the locked dev version)
    • import declarative_base from sqlalchemy.orm instead of the deprecated ext.declarative path
    • set __allow_unmapped__ = True on Base, so existing models written as col: SqlColumn = Column(...) (including generated model files) keep working on 2.0 without regeneration
    • annotate the creator_id / creator declared_attrs with Mapped[...], which 2.0 requires
    • add a CI step that also runs the test suite on SQLAlchemy 2.0

    Locally, all 19 tests pass on Python 3.10, 3.12 and 3.13 with both SQLAlchemy 1.4.53 and 2.0.57 (on 2.0 with SQLAlchemy deprecation warnings turned into errors), and pre-commit run -a passes.

    Would you be open to a PR for this? Happy to adjust the approach if you'd prefer something different.

    Full disclosure: I used an AI coding assistant to help with this, and I've reviewed and tested every change myself. Sorry if this is an unwelcome interruption. I'm just trying to use AI to make things a little easier for people, and hopefully earn a bit of extra money for my family along the way. This contribution is completely free, no strings attached.

  4. steve-dyno commented on Nov 11, 2026

    @steve-dyno

    We at Dyno are now starting to consider prioritizing a sql alchemy 2 upgrade, so I would say this is back on the table. If anything, this upgrading Liminal to sqlalchemy 2 would just be more incentive for us to make the push.

  5. xravitycapital commented on Nov 11, 2026

    @xravitycapital

    Thanks @steve-dyno, that's great to hear! I've opened #284 with the change described above. It keeps 1.4 working, so you can merge it and still upgrade Dyno on your own schedule. Happy to adjust anything, and no rush at all.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions