Skip to content

v2.6.0

Latest

Choose a tag to compare

@jedymatt jedymatt released this 07 Jul 12:40
ee3257a

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, hybrid filter on relationships and FK columns, one-to-many lists, AsyncSeeder via sqlmodel.ext.asyncio, the bundled pytest plugin against a SQLModel engine, and CSV via model. (sqlmodel stays a test-only dependency β€” nothing new is required at runtime.)
  • HybridSeeder migrated off legacy session.query() to 2.0-style select(), so using a sqlmodel.Session no 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: a data key that names a relationship attribute (e.g. company instead of !company) was silently dropped before. It now emits a UserWarning β€” or raises InvalidKeyError under strict=True β€” telling you the prefix you probably meant.
  • List bound to a scalar relationship: binding a multi-item list to a uselist=False relationship silently kept only the last element. It now warns (or raises under strict=True) instead of losing data.
  • schema.json accepts an empty top-level object again, matching the runtime validator β€” placeholder seed files no longer show editor errors.

πŸ› Fixes

  • util.get_model_class raised a bare TypeError instead of the intended errors when given a bad model path or an unmapped class; it now raises InvalidModelPath / UnsupportedClassError with clear messages.

Compatibility

  • No breaking changes: strict defaults to False. Seed files with forgotten relationship prefixes or list-to-scalar bindings will start emitting UserWarnings β€” 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