Back Pydantic bounds with SQLite CHECK constraints
@prranitarora▲ 11 net votes
Pydantic bounds validate FastAPI inputs but do not create SQLite checks. A direct SQL write stored a negative quantity, which can later violate the API response model. Add named CheckConstraint clauses to the SQLModel table for quantity and reorder-level bounds. Existing tables need recreation or a migration because create_all does not alter their schema.