Skip to content

fix: name psycopg2 in the Alembic DSN and cap sqlalchemy below 2.1 - #39

Merged
lesnik512 merged 2 commits into
mainfrom
fix/alembic-names-its-driver
Sep 27, 2026
Merged

lesnik512 merged 2 commits into
mainfrom
fix/alembic-names-its-driver

Conversation

@lesnik512

@lesnik512 lesnik512 commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Closes #38. Follow-up to lift the cap: #40.

What

  • Settings.sync_db_dsn_parsed sets drivername="postgresql+psycopg2" instead of "postgresql"; the test that pinned the old value now pins the driver.
  • sqlalchemy[asyncio]<2.1.

Why

SQLAlchemy 2.1.1 (2026-09-25) arrived through the fresh resolve and broke the pytest jobs in three independent ways:

  1. postgresql:// now means psycopg (3), so alembic upgrade head imported a driver this project does not depend on. Naming the driver fixes the URL's meaning regardless of SQLAlchemy's default (option 1 from CI: pytest jobs fail on a fresh resolve because SQLAlchemy 2.1 resolves postgresql:// to psycopg 3 #38; psycopg 3 is a separate decision).
  2. advanced-alchemy 1.11.0 (latest) does not translate 2.1's asyncpg integrity errors: its regexes expect a DETAIL line that 2.1 no longer includes (Bug: DuplicateKeyError not raised on SQLAlchemy 2.1 with asyncpg (regex no longer matches) litestar-org/advanced-alchemy#803, fix PR open). Duplicate username and unknown member id return 500 instead of 409/400. Confirmed independent of anything here by running the suite on 2.1.1 with this repo's models untouched.
  3. Two deprecations surface as errors under filterwarnings = ["error"]: advanced-alchemy's @declarative_mixin (#804) and this repo's lazy="noload".

(2) has no fix on our side, so the cap is the honest change; (3) is recorded in #40 with the verified replacement (lazy="raise"), to land when the cap lifts.

Verified

  • Red first: test_sync_db_dsn_parsed_names_the_sync_driver fails against the old drivername ('postgresql' == 'postgresql+psycopg2'), green after the settings change.
  • Full suite in Docker on the capped resolve (SQLAlchemy 2.0.54): 117 passed, 100% coverage.
  • ruff format, ruff check, ty clean.

@lesnik512 lesnik512 changed the title fix: name psycopg2 in the Alembic DSN and ignore advanced-alchemy's SQLAlchemy 2.1 deprecation fix: name psycopg2 in the Alembic DSN and cap sqlalchemy below 2.1 Sep 27, 2026
@lesnik512
lesnik512 merged commit 9ee2b02 into main Sep 27, 2026
4 checks passed
@lesnik512
lesnik512 deleted the fix/alembic-names-its-driver branch September 27, 2026 20:26
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.

CI: pytest jobs fail on a fresh resolve because SQLAlchemy 2.1 resolves postgresql:// to psycopg 3

1 participant