Improvements to Relationships, updated documentation #5
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.
Summary
Enhance relationship handling with lazy loading policies and explicit relationship control, providing better flexibility and performance optimization for data fetching.
Changes
New Features
Lazy Loading Policies (
lazyparameter)"forbid"- Raise an error when accessing unjoined relationships (strictest, prevents N+1 queries)"warn"- Return empty value with RuntimeWarning (matches previous behavior)"ignore"- Return empty value silently"tolerate"- Fetch data on-demand with performance warning (new default)"allow"- Fetch data on-demand silentlyConfigure globally via
TypeDALConfig.lazy_policyor per-relationship viarelationship(..., lazy="forbid").Explicit Relationships (
explicitparameter)Mark relationships as only loading when explicitly requested:
Enhanced
join()APIRelationshipinstances directly:Article.join(Article.tags, method="inner")Article.join("author", Article.tags)conditionandonparametersexplicit=Truein bare.join()calls (only joins explicitly requested relationships)Improved Descriptor Behavior
__set_name__to automatically track relationship field names__get__Configuration
TypeDALConfig.lazy_policysetting (default:"tolerate")pyproject.toml[tool.typedal]sectionlazyparameterOther Improvements
__eq__method to TypedTable instances for row-based comparisonTesting
Documentation
This release includes a comprehensive documentation update covering the changes in this release as well as several previous releases:
.where()examples,.orderby()usage, raw SQL expressions, and links to relationships documentation