Handle belongs_to :through, :polymorphic: true#336
Open
kbrock wants to merge 3 commits intoactive-hash:masterfrom
Open
Handle belongs_to :through, :polymorphic: true#336kbrock wants to merge 3 commits intoactive-hash:masterfrom
kbrock wants to merge 3 commits intoactive-hash:masterfrom
Conversation
We undefine these classes in the after {}
So in theory, they should not be a duplicate.
rspec often uses stub_const, but active record has issues with this since
they dig into the class.name and stuff
f91dc58 to
b3a12f3
Compare
Move class resolution out of definition time and into method bodies. Call super first so AR registers reflections (preserving eager loading support), then override accessors with runtime ActiveHash checks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When source_type is present, resolve the class at runtime and look up by foreign key directly, bypassing AR's polymorphic belongs_to which does not work with ActiveHash. Fixes active-hash#334. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
update: removed class load |
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.
Thank you, @alexgriff, for the outline.
belongs_to_active_hashis no longer called.There is a lock on loading the schema. There is a lock to load a class. When you access the schema at class load time, but then access another class that needs to be loaded, you get a deadlock.
So changed the code to avoid.
Fixes #334