Skip to content

The server's checks assume SQLAlchemy 2.0, while every fresh install resolves 2.1 #164

Closed

Description

@lumenpearson

server/pyproject.toml and requirements.txt both ask for sqlalchemy[asyncio]>=2.0.54, with no ceiling. Since SQLAlchemy 2.1.0 was published, a fresh install resolves 2.1.x (2.1.1 today): CI's pip install -e ".[dev]" does, and so does Vercel's install for production. A checkout that was set up before that date keeps 2.0.54 until somebody upgrades it. Two checks behave differently between the two versions:

  1. CI goes red on PR Read «Сетевой город» as a second diary, and let a phone in through its own school's diary #140. tests/test_quota.py::test_the_spend_on_postgres_is_one_guarded_upsert compiles the Postgres upsert and compares its text word for word. 2.1 writes an explicit cast after every bind parameter on the Postgres dialect (%(used_2)s::INTEGER <= %(param_1)s::INTEGER), and 2.0 does not. The test passed on 2.0.54 in the session that wrote it and failed on CI at 6b0878f with 1 failed and 1997 passed. The statement is correct on both versions; the assertion is what is wrong.
  2. python -m mypy is no longer clean on main. 2.1 types the rows of session.execute(select(A, B)) as (A, B) rather than Any, so app/services/reminders.py:290 compares PersonalTask.remind_at, which is datetime | None, with <=. mypy reports Unsupported operand types for >= ("datetime" and "None"). CLAUDE.md says mypy is clean. The query's WHERE remind_at IS NOT NULL means no None ever reaches that line at run time, so this is a check that broke, not behaviour that broke. mypy is not in CI, which is why nothing turned red on main.

The rest of the suite passes on 2.1.1 (1998 passed, run locally against 2.1.1). Production has been running whatever version the install resolves ever since 2.1 was published.

Fix: make the SQL assertion tolerate bind casts, and put an explicit is not None guard where the type checker can see it. Pinning <2.1 is deliberately not the fix: production already runs 2.1, and a pin would test something other than what is deployed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions