Allow ancestry to define a primary ancestry key#747
Open
kbrock wants to merge 1 commit intostefankroes:masterfrom
Open
Allow ancestry to define a primary ancestry key#747kbrock wants to merge 1 commit intostefankroes:masterfrom
kbrock wants to merge 1 commit intostefankroes:masterfrom
Conversation
57bf3c5 to
2c0362a
Compare
Introduce primary_ancestry_key class variable and ancestry_id instance method as the indirection point for which column values are stored in ancestry paths. Defaults to :id. On Rails 7.2+, auto-detects from primary_key. On older Rails, must be passed explicitly via has_ancestry primary_key: :code. Replaces bare id/node.id with ancestry_id/node.ancestry_id throughout static modules (instance_methods.rb, class_methods.rb) and builder. Replaces scope.primary_key with scope.primary_ancestry_key for record lookups by ancestry values. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2c0362a to
3eb79fa
Compare
Collaborator
Author
|
@a5-stable does this look like it would meet your needs? I'm trying to see if there is a way to patch this in or changes I can make in core so it is easier to patch. Have gotten this to be less invasive, but it sure goes everywhere. I was hoping that I could localize the changes just to the builder. Haven't gotten there yet and a little stuck. |
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.
Description
Not sure if I want to commit, but putting this out there.
Many of the concepts are good. But not as readable as I'd like.
A lot of change, so this will get stale quickly.
Fixes #698
This allows ancestry to have
a/b/c/but the primary keys be1,2,3Before
After
Type of Change
Checklist
bundle exec rake test)How Has This Been Tested?