feat: fix polymorphic relationship descriptors and add test coverage#70
Open
bedus-creation wants to merge 3 commits into
Open
feat: fix polymorphic relationship descriptors and add test coverage#70bedus-creation wants to merge 3 commits into
bedus-creation wants to merge 3 commits into
Conversation
…est coverage - Add `if instance is None: return self` guard to MorphMany, MorphOne, MorphToMany __get__ - Fix morph_map() to use registry.Registry.get_morph_map() instead of broken load_config().DB._morph_map - Fix get_record_key_lookup to use Registry._reverse_map for O(1) lookup and correct alias resolution - Fix apply_query in MorphMany/MorphOne to pass the model instance (not the builder's class) to get_record_key_lookup - Add delete_attribute() helper to Attribute for cleaning up transient pivot attributes - Add table() and without_global_scopes() helpers to QueryBuilder - Add tests for BelongsToMany, MorphMany, MorphOne, and MorphToMany relationships Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
27dc66c to
f8904f9
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
f8904f9 to
b62a524
Compare
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.
Summary
__get__descriptor inMorphMany,MorphOne, andMorphToManyto returnselfon class-level access (instance is None), preventingAttributeErroron class-attribute accessmorph_map()inMorphOneandMorphToManyto useregistry.Registry.get_morph_map()instead of the brokenload_config().DB._morph_mapget_record_key_lookupto useRegistry._reverse_mapfor correct alias resolution (previously iterated the forward map in insertion order, finding auto-registered class names before explicit aliases)apply_queryinMorphMany/MorphOneto pass the model instance toget_record_key_lookup, not the builder's model classdelete_attribute()toAttributefor cleaning up transient pivot columns after eager loadingtable()andwithout_global_scopes()helpers toQueryBuilderBelongsToMany,MorphMany,MorphOne, andMorphToManyTest plan
uv run pytest tests/masoniteorm/sqlite/relationships/ -v— all relationship tests passuv run pytest --ignore=tests/masoniteorm/postgres -v— full suite passes without regressions🤖 Generated with Claude Code