Repository navigation
fix(models): expressions on inherited fields use the subclass's datetime_format - #111
Merged
kalaspuff merged 7 commits intoOct 31, 2026
Merged
Conversation
…ime_format A native model that inherits a field reused the path object of the class that declared it, so `Article.seen_at` encoded values with the schema of the abstract `Timestamped`. When the subclass sets another `datetime_format`, filters, key and write conditions compared text in the base class's format with what the subclass stores and found nothing, and updates stored values in the base class's format. Transactions took the declaring class as the model of updates by key (`Timestamped is not stored in a table`), and assigning or comparing an inherited field failed when the base class's schema could not be built on its own (a key template naming a field of the subclass). Every native model and document class now gets paths of its own for the fields it inherits, as pydantic models already did. The paths of the base class keep the base's format. Fixes #79 Co-authored-by: Carl Oscar Aaro <[email protected]>
…com-kalaspuff-dynamoxy-issu Both sides added a Fixed entry to CHANGELOG.md and tests at the end of tests/unit/test_pydantic.py: keep both, main's first. Co-authored-by: Carl Oscar Aaro <[email protected]>
…com-kalaspuff-dynamoxy-issu Both sides added a Fixed entry to CHANGELOG.md: keep both, main's first. Co-authored-by: Carl Oscar Aaro <[email protected]>
This comment has been minimized.
This comment has been minimized.
Since each class has paths of its own, the instance methods add(),
increment() and decrement() refuse the path of a sibling class that
inherits the same field, as they already did for pydantic models:
with Page and Post both inheriting views, post.increment(Page.views)
raises TypeError. Pin that with a test on native and pydantic models,
name the attribute to use in the message ("use Post.views"), and say
it in the changelog.
Co-authored-by: Carl Oscar Aaro <[email protected]>
…com-kalaspuff-dynamoxy-issu Both sides added a Fixed entry to CHANGELOG.md (keep both, main's first) and a test model import to tests/integration/test_transactions.py (import both Article and Player). Co-authored-by: Carl Oscar Aaro <[email protected]>
…com-kalaspuff-dynamoxy-issu Both sides added a Fixed entry to CHANGELOG.md: keep both, main's first. Co-authored-by: Carl Oscar Aaro <[email protected]>
…com-kalaspuff-dynamoxy-issu Both sides added a Fixed entry to CHANGELOG.md: keep both, main's first. Co-authored-by: Carl Oscar Aaro <[email protected]>
kalaspuff
deleted the
fctl/57-https-github-com-kalaspuff-dynamoxy-issu
branch
October 31, 2026 00:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Native models reused the path object of the class that declared a field, so the fields a subclass inherits (
Article.seen_at, declared by an abstractTimestamped) encoded expression values with the declaring class's schema. WithArticle(Timestamped, datetime_format="iso_z"),put()stored...Z, butfilter(Article.seen_at == at)and key and write conditions rendered...+00:00and matched nothing (with an epoch format they rendered text where numbers are stored), andupdate(Article.seen_at.set(at))stored...+00:00among...Zvalues. The same cause made transactions take the declaring class as the model of an update by key:tx.update(Article.key(...), Article.seen_at.set(at))raisedTypeError: Timestamped is not stored in a table. And assigning or comparing an inherited field failed when the base class's schema cannot be built on its own, for example when its key template names a field of the subclass.Every native model and document class now gets paths of its own for the fields it inherits, bound to its own schema, as pydantic models already did. The paths of the base class keep the base's format. The modeling guide and AGENT_GUIDE now say to build conditions and updates from the class you read or write.
Verified with new tests that fail without the fix: an integration test on the in-memory backend and MiniStack (put, a key condition with an inclusive bound, a filter and a conditional update), a transaction's update by key on both backends, instance methods given the paths of sibling classes (native and pydantic, both backends), and unit tests of the encoded values, a deeper subclass, error messages and a base class whose schema cannot be built. A pydantic test keeps both kinds of models equal.
make checkpasses, and the affected test modules pass on Python 3.12 too.Fixes #79
Checklist
AGENT_GUIDE.md, changelog)make checkpasses locally (lint, types, clippy, consistency, tests; no Rust change)Worth confirming
client.model(Article).scan().filter(Timestamped.seen_at == at)still compares...+00:00. The issue asked for subclass paths, and making a base class's paths follow the repository's model would mean encoding values when a request is built rather than when the expression is. The guides say to use the class you read or write instead.add(),increment()anddecrement()refuse the path of a sibling class, as they already did for pydantic models. WithPageandPostboth inheritingviews,post.increment(Page.views)raisesTypeError: Page.views is not a field of Post: use Post.views, where native models accepted the shared path before; the changelog says so. The class's own path and the base class's still work.fctl session
Note
Medium risk. It changes how every native model and document class collects its fields: each subclass now gets path objects of its own for inherited fields, so
Subclass.fieldis a different object than before, and instance methods now refuse a sibling class's path.What it does. Fixes expressions on fields that a subclass inherits: conditions, filters and updates built from
Article.seen_atused thedatetime_formatof the abstract class that declared the field, not of the subclass that stores it. A subclass now gets paths of its own for the fields it inherits, bound to its own schema, which also fixes transactions picking the declaring abstract class as the model of an update by key and theTypeErrorwhen a base class's key template names a subclass field. Tests cover native and pydantic models on the in-memory backend and MiniStack, and the modeling guide, agent guide and changelog are updated.Base-class and sibling paths. Paths taken from a base class still encode values in the base's format, so conditions must be built from the class being read or written. Instance methods such as
increment()now refuse the path of a sibling class:post.increment(Page.views)raisesTypeErrornamingPost.views, where the shared path was accepted before.fctl review's first look at
3cf2ea3· 11 files, +213 −9 · Review agent settings