Skip to content

Commit d5bf5a1

Browse files
committed
docs(model): correct the model and config docstrings
Ten findings from the 2026-08-13 audit, all in the published API reference: - M1 bind() claimed every config key can be bound late; it has no use_revision parameter and _config.py says the opposite. Names the five bindable keys, states the exception, and gains the Args and Raises sections it never had. - M2 update() claimed "every other write verb" enforces Unique. Four update verbs do not. Names the six instance-level writes that enforce and the five update verbs that do not. - M3 update()'s summary said non-field keys "pass through unchanged" — true only under extra_keys="allow", not the "reject" default its own Args section documents. - M4 insert_many()'s Raises omitted UniqueConstraintError. - M5 twelve Raises omissions across four exception types (UniqueConstraintError, RevisionUpdateError, QueryTypeError, pydantic.ValidationError) on the public read and write verbs. The raising helpers are private, so the reference surfaced them nowhere. - M6 __pydantic_init_subclass__ omitted ConstraintFieldError. - M7 the before_write no-hook list named two verbs where five apply, and _config.py's validate_writes note named a different incomplete pair. - M8 the metaclass and field() described class-level access as returning where(), not a GuardedQuery — contradicting _query.py in the same reference. - M9 "transform callable is handed to TinyDB as-is" describes only the validate_writes=False fast path; on every other path tinydantic runs it, rotates revision_id after it, and validates its output. - M10 an orphaned comment, upsert()'s missing Args, search()'s missing Args and Returns, the extra="forbid" caveat on merged validation, and the order-insensitive constraint collapse now linked to #142. Also refreshes _check_doc_ids_exist's stale `doc_ids=` spelling. Assisted-by: Claude:claude-opus-5
1 parent 297faa0 commit d5bf5a1

3 files changed

Lines changed: 196 additions & 53 deletions

File tree

‎docs/usage/crud.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ Book(id=3, title='Snow Crash', author='Stephenson', year=1993, in_stock=True)
312312
Update mappings cannot set `id` — it maps to TinyDB's `doc_id`, which an update cannot change. Trying raises [DocumentIDUpdateError][tinydantic.DocumentIDUpdateError]:
313313

314314
```pycon
315-
>>> Book.update({"id": 99}, Book.title == "Dune") # doctest: -IGNORE_EXCEPTION_DETAIL
315+
>>> Book.update(
316+
... {"id": 99}, Book.title == "Dune"
317+
... ) # doctest: -IGNORE_EXCEPTION_DETAIL
316318
Traceback (most recent call last):
317319
...
318320
tinydantic._errors.DocumentIDUpdateError: update() cannot set 'id' on 'Book'

‎src/tinydantic/_config.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ class name converted to snake_case — for example, a model class
111111
112112
When True (the default), every write refuses to persist a
113113
document body that would fail validation on its next read:
114-
whole-model writes validate their serialized payload, and
115-
``update()``/``update_many()`` validate each matched
116-
document's merged result before anything is written. Set False
114+
whole-model writes validate their serialized payload, and the
115+
update verbs (``update()``, ``update_by_ids()``,
116+
``update_all()``, ``update_many()``, and
117+
``FindQuery.update()``) validate each matched document's
118+
merged result before anything is written. Set False
117119
to skip this re-validation — the escape hatch for
118120
performance-critical bulk writes, where per-document
119121
validation cost matters more than the guarantee.

0 commit comments

Comments
 (0)