litestar-org / litestar

Production-ready, Light, Flexible and Extensible ASGI API framework | Effortlessly Build Performant APIs
https://litestar.dev/
MIT License
5.66k stars 384 forks source link

Enhancement: Update SQLAlchemy Plugin to use SQLA 2.0 #983

Closed Goldziher closed 1 year ago

Goldziher commented 1 year ago

We should update the SQLAlchemy for SQLA 2.0 compatibility. The plugin should be compatible with both v1.4.* and v2.0.0.

peterschutt commented 1 year ago

should we add a test matrix to ci that tests specifically across the two sqlalchemy major versions?

peterschutt commented 1 year ago

Here's a tox.ini that will run the test suite against both 1.4 and 2.0:

[tox]
env_list = sa{14,20}
isolated_build = true

[base]
deps =
    aiomcache
    aiosqlite
    beanie
    beautifulsoup4
    brotli
    click
    cryptography
    fakeredis
    freezegun
    fsspec
    greenlet
    hypothesis
    jinja2
    jsbeautifier
    mako
    mongomock-motor
    opentelemetry-instrumentation-asgi
    opentelemetry-sdk
    piccolo
    picologging
    pre-commit
    pytest
    pytest-asyncio
    pytest-cov
    pytest-mock
    python-dotenv
    python-jose
    redis
    rich
    starlette
    structlog
    tortoise-orm
    trio
    uvicorn

[testenv]
setenv =
    PATH = {toxinidir}/tests{:}{env:PATH}
extras = full
commands = pytest

[testenv:sa14]
deps =
    sqlalchemy~=1.4
    {[base]deps}

[testenv:sa20]
deps =
    sqlalchemy~=2.0
    {[base]deps}

If you have tox installed globally (e.g., pipx install tox) dump this in starlite root and run tox.