Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matching by role type without scope incorrectly rejects query #7014

Open
flyingsilverfin opened this issue Mar 26, 2024 · 0 comments
Open

Matching by role type without scope incorrectly rejects query #7014

flyingsilverfin opened this issue Mar 26, 2024 · 0 comments

Comments

@flyingsilverfin
Copy link
Member

Description

If a user queries using just the roles of relations, without specifying the relation types, TypeDB can accidentally Alias the role types together, and cause the query to be rejected.

Environment

  1. TypeDB distribution: Core/Cloud
  2. TypeDB version: 2.10 onwards

Reproducible Steps

define
  person sub entity;
  pet sub entity;
  toy sub entity;
  pet-ownership sub relation, relates owner, relates pet;
  toy-ownership sub relation, relates owner, relates toy;
  person plays pet-ownership:owner;
  pet plays pet-ownership:pet, plays toy-ownership:owner;
  toy plays toy-ownership:toy;
match
  (owner: $x, pet: $y);
  (owner: $y, toy: $z);
get;

We get:

[CXN05] The transaction is closed because of the error(s):
[QRY16] Invalid Query Pattern: Could not infer compatible types for the match pattern:
'{{ 
$_1 (owner:$y, toy:$z); 
$_0 (owner:$x, pet:$y); 
}}'

Expected result

We should find that the query is satisfiable, returning person that have pets, where the pets have toys.

Additional information

TypeDB receives type labelled variables:
relation:owner, relation:pet, relation:owner, and relation:toy
Due to receiving the same type label twice, we then construct a query graph with only one Type Variable for relation:owner! However, these should be kept separate and wired up to the neighbors.

This will require allowing anonymous type variables, and generating a new type variable with an anonymous name for each scoped type label (and the label constraint), and then allowing Type inference to resolve the labels on the variables independently.

@flyingsilverfin flyingsilverfin changed the title Matching by role type without scope causes incorrect query rejection Matching by role type without scope incorrectly rejects query Mar 26, 2024
@flyingsilverfin flyingsilverfin added this to the 3.0.0 milestone Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant