Pydantic v2 Textbook Ch. 4 — Serialization in Depth
Output side: model_dump, model_dump_json, field/model serializers, exclude/include, mode=python/json, by_alias.
Output side: model_dump, model_dump_json, field/model serializers, exclude/include, mode=python/json, by_alias.
Session deep dive: lifecycle, identity map, flush, commit, expire_on_commit, refresh, the unit of work.
Cheatsheet: iter/next, generators, async generators, comprehensions, itertools.
Cheatsheet: full auth stack — User model, login endpoint, token deps, refresh, password hashing.
Cheatsheet: expand-contract pattern, CONCURRENTLY index, FK validation in two phases, batched backfill.
Cheatsheet: discriminator field, callable Discriminator, Generic[T] models, recursive references.
Cheatsheet: relationship(), back_populates, secondary, cascade, joinedload / selectinload / subqueryload, lazy options.
Zero-downtime migrations: expand-contract, batched backfills, CONCURRENTLY, NOT VALID FK, and pg_repack.
Composing models: nesting, generics with TypeVars, discriminated unions, recursive models.
Selecting rows in SQLAlchemy 2.0: select(), where, joins, group_by, aggregates, subqueries, CTEs, scalars vs rows.