Highlights
π First-class SQLModel & FastAPI support (#76)
SQLModel table=True classes are real SQLAlchemy mapped classes, so sqlalchemyseed works with SQLModel and FastAPI out of the box β same seed files, same seeders, same CLI and pytest plugin. This release turns that from "probably" into "proven":
- A dedicated compatibility suite now runs in CI on every push: nested
!refs, hybridfilteron relationships and FK columns, one-to-many lists,AsyncSeederviasqlmodel.ext.asyncio, the bundled pytest plugin against a SQLModel engine, and CSV viamodel. (sqlmodelstays a test-only dependency β nothing new is required at runtime.) HybridSeedermigrated off legacysession.query()to 2.0-styleselect(), so using asqlmodel.Sessionno longer fills pytest output with DeprecationWarnings from inside this library. Filter semantics are unchanged (NoResultFound/MultipleResultsFound, autoflush parity).- New docs: FastAPI & SQLModel β models, app-startup seeding via
lifespan, testing with the pytest plugin, CLI, and async.
Requires sqlmodel>=0.0.22 if you use SQLModel.
π‘οΈ New: opt-in strict mode + seeding guards
Seeder, HybridSeeder, and the async seeders accept strict=True (default False), and two silent-failure paths now speak up:
- Forgotten
!prefix: adatakey that names a relationship attribute (e.g.companyinstead of!company) was silently dropped before. It now emits aUserWarningβ or raisesInvalidKeyErrorunderstrict=Trueβ telling you the prefix you probably meant. - List bound to a scalar relationship: binding a multi-item list to a
uselist=Falserelationship silently kept only the last element. It now warns (or raises understrict=True) instead of losing data. schema.jsonaccepts an empty top-level object again, matching the runtime validator β placeholder seed files no longer show editor errors.
π Fixes
util.get_model_classraised a bareTypeErrorinstead of the intended errors when given a bad model path or an unmapped class; it now raisesInvalidModelPath/UnsupportedClassErrorwith clear messages.
Compatibility
- No breaking changes:
strictdefaults toFalse. Seed files with forgotten relationship prefixes or list-to-scalar bindings will start emittingUserWarnings β each one points at real silently-dropped or silently-overwritten data worth fixing. - Requires Python >=3.10, SQLAlchemy >=2.0. SQLModel remains optional.
Full changelog: v2.5.0...v2.6.0