Repository navigation
1.16.0 — construction semantics
Construction semantics release: an instance now agrees with the row it writes in four places that previously needed application-side shims, plus a bulk_update batching fix. Highlights:
Added
Model.__iter__: instances iterate as(name, value)pairs, sodict(instance)works and pair-walking consumers (pydanticfrom_attributes, serializers, factories) take a model directly. Declared columns first in declaration order, columns absent underonly()/defer()skipped rather than fetched, private attributes omitted,Meta.extra_kwargs = "store"extras last.
Changed
- An explicit
<name>_idwins over a relation object at construction.Book(author=obj, author_id=x)used to storeobj.pk; it now keepsx(by field name or db-column alias), and an object whose pk disagrees is not cached as the prefetched relation. Factories need this: aSubFactoryis evaluated even when the caller passesauthor_id=. Passing only one form is unchanged. auto_now_addfills the column instead of imposing a value. Backdated fixtures, imports and backfills keep the stamp they pass.auto_nowstill always stamps, as does a field declaring both.
Fixed
- Foreign-key columns are coerced on assignment.
create(parent_id=str(pk))left the rawstron the instance, sochild.parent_id == parent.idwasFalseuntil re-fetch.ForeignKeyFieldInstance.to_python_valuenow mirrorsto_dband the<name>_idcolumn is normalised in__init__like every other coerced column. bulk_updaterespects the dialect's bind-parameter ceiling. Batches are clamped frommax_bind_params(each row costs a(pk, value)pair per field plus a pk slot inWHERE ... IN), so a largebatch_sizeno longer overflows PostgreSQL's 65535 / SQL Server's 2100 limit; SQLite now declares its default 32766.
Full details in CHANGELOG.md.