Add regression test for #7014: matching by role type without scope#7846
Open
SBALAVIGNESH123 wants to merge 1 commit into
Open
Add regression test for #7014: matching by role type without scope#7846SBALAVIGNESH123 wants to merge 1 commit into
SBALAVIGNESH123 wants to merge 1 commit into
Conversation
Adds a unit test to verify that matching by unscoped role type names does not incorrectly reject queries when multiple relation types share the same role name. The test reproduces the exact schema and query from the issue report and confirms that type inference produces correct, non-empty type annotations for all variables. Closes typedb#7014
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
This PR adds a regression test confirming that issue #7014 has been resolved in the 3.x codebase. The bug reported that when two different relation types share the same role name (like
owner), querying by the unscoped role name would incorrectly reject the query as unsatisfiable. After a thorough investigation of the type inference pipeline, I've confirmed that the 3.x Rust rewrite handles this case correctly and the query is no longer rejected.Background
The original issue described a scenario with two relation types that both declare a role called
owner:The query
match (owner: $x, pet: $y); (owner: $y, toy: $z); get;should return results where$xis a person,$yis a pet, and$zis a toy. In TypeDB 2.x, this query was incorrectly rejected because the type inference engine would alias the two occurrences of theownerrole label into a single type variable.Root Cause Analysis
In the 2.x Java implementation, role labels with the same name were mapped to the same type variable. The 3.x Rust rewrite fixed this through a redesign of the IR translation layer. The function
register_type_role_name_varinir/translation/constraints.rsnow callscreate_anonymous_variable()for every occurrence of a role label, ensuring each mention ofownergets its own independent variable. This means the type inference engine treats each role position independently, which is the correct behavior.What Changed
Added a single regression test
test_issue_7014_unscoped_role_name_not_aliasedtocompiler/annotation/type_seeder.rs. The test sets up the exact schema from the issue, constructs the IR for the reproducing query, runs type inference, and verifies that:$xincludesperson,$yincludespet, and$zincludestoy.Closes #7014