fix bug for multiple backlinks with the same property id, but different type targets#573
Merged
fix bug for multiple backlinks with the same property id, but different type targets#573
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where multiple backlinks with the same property ID but different target type IDs would collide, causing incorrect data retrieval. The fix introduces target type IDs into the relation alias generation to ensure unique aliases for each relation configuration.
Key Changes
- Modified
getRelationAliasto accept an optionaltargetTypeIdsparameter and incorporate it into the alias through canonicalization - Added comprehensive test coverage for the new alias generation logic
- Updated all call sites to pass
targetTypeIdswhen available - Added test entities (
PersonHostTest,EpisodeHostTest,PodcastHostTest) to demonstrate the bug scenario
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/hypergraph/src/utils/relation-query-helpers.ts | Extended getRelationAlias to include target type IDs in the alias, added helper functions for sanitization and canonicalization |
| packages/hypergraph/src/utils/convert-relations.ts | Updated to pass targetTypeIds when calling getRelationAlias |
| packages/hypergraph/test/utils/relation-query-helpers.test.ts | Added new test file with comprehensive coverage for alias generation logic |
| packages/hypergraph/test/utils/relation-config-overrides.test.ts | Updated to dynamically compute relation alias instead of using hardcoded string |
| packages/hypergraph/test/entity/find-one-public.test.ts | Updated to properly compute relation alias with target type IDs |
| packages/hypergraph/test/entity/find-many-public.test.ts | Updated to properly compute relation alias with target type IDs |
| apps/events/src/schema.ts | Added test schemas demonstrating the bug scenario with duplicate property IDs |
| apps/events/src/routes/podcasts.lazy.tsx | Added example usage of the new test schemas to verify the fix works |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.