Skip to content

Fix polymorphic relationship handling in FixtureService#36

Merged
chrispenny merged 3 commits intomainfrom
fix/polymorphic-relationships
Mar 29, 2026
Merged

Fix polymorphic relationship handling in FixtureService#36
chrispenny merged 3 commits intomainfrom
fix/polymorphic-relationships

Conversation

@chrispenny
Copy link
Copy Markdown
Owner

Builds on #32 by @jsirish (sorry, I didn't have access to the fork to be able to push new commits)

Closes #32

jsirish added 2 commits March 30, 2026 10:42
When has_one relationships are configured as arrays (polymorphic relationships),
the code was failing with a fatal error trying to check if the array value existed
as a class configuration.

This fix:
- Checks if relationClassName is an array
- Extracts the 'class' key for polymorphic relationships
- Adds proper warning handling for invalid configurations
- Validates that field_classname_map returns valid class names

Fixes fatal error: DataObject::get() cannot query non-subclass DataObject directly
when processing polymorphic has_one relationships defined as arrays.
… messages

- Extract polymorphic relationship logic into dedicated handlePolymorphicRelationship() method
- Replace var_export with json_encode for cleaner warning output
- Add better error handling for unexpected relationship types
- Addresses review feedback from PR #32
@chrispenny chrispenny force-pushed the fix/polymorphic-relationships branch from 4523f94 to 98c49e0 Compare March 29, 2026 21:58
@chrispenny chrispenny force-pushed the fix/polymorphic-relationships branch from 98c49e0 to f5699bc Compare March 29, 2026 22:02
@chrispenny chrispenny merged commit e4d36c0 into main Mar 29, 2026
18 checks passed
@chrispenny chrispenny deleted the fix/polymorphic-relationships branch March 29, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants