You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Models: subclass instances, keys stored in non-canonical text, and nested attributes of newer versions #99
Subclass instances are stored as the base model (repository.py, writes accept any isinstance match and encode with the repository's schema): client.model(User).create(Admin(level=9)) stores _type: "User" and drops level; client.model(User).get(...) of an Admin item returns a User, whose save() rewrites _type, so Admin.query no longer finds it. A document field typed as a base class drops a subclass instance's extra fields. Refuse instances of other models, or write them through their own repository.
Keys stored in non-canonical text make loaded instances address another key (codecs.py accepts any parseable text; repository.py renders the key from the instance's values): a UUID key stored upper-case by another writer reads back, but the instance renders the lower-case key, so delete() deletes nothing, refresh() raises ItemNotFoundError and save() raises "key changed". A date key stored as 20260102 renders as 2026-01-02. ADR 0015 says keys of loaded instances are the stored keys.
Saves by an older version of an application erase nested attributes a newer one added (_with_undeclared keeps top-level attributes only): a new top-level attribute survives, address.zip_code does not. ADR 0014 covers top-level attributes only, but AGENT_GUIDE.md says older versions "do not erase what a newer one wrote".
Found in a review of the library for bugs (fctl session); the fixes that fit in its ten pull requests are #61 to #65, #67 to #70 and #72.
Activity
fix(models): documents read from an item keep the keys their class do…
fix(models): writes through loaded instances use keys stored in anoth…
fix(models): repositories refuse instances of subclasses and items of…
fix(models): documents read from an item keep the keys their class do…