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

Allow disjoint types in type labels #232

Open
flyingsilverfin opened this issue Sep 30, 2022 · 1 comment
Open

Allow disjoint types in type labels #232

flyingsilverfin opened this issue Sep 30, 2022 · 1 comment

Comments

@flyingsilverfin
Copy link
Member

Problem to Solve

We can easily implement an extension to TypeQL - a union/disjunction of types, as an alternative to a single type label. This would make a single TypeQL query expressive without having to resort to disjunctions or separate queries.

Current Workaround

To query for instances of two types, we must do for example:
match $x isa $t; { $t type person;} or { $t type house;};
or run two separate queries.

Proposed Solution

We could instead write match $x isa person|house;, which allows lumping two possibly disjoint types into the Label for the isa.

This should work for anything in the query that contains a Label constraint, and can be directly implemented by extending the grammar and the parsed Constraint to support a set of label strings.

@dmitrii-ubskii
Copy link
Member

This may be a bigger change than was initially thought.

Because the type constructs are shared between different kinds of queries, viz. match and define, allowing a label to be a union of labels across the board would lead to define foo sub bar|baz, owns name|age; being a valid query from the grammar's point of view. It wouldn't make a whole lot of sense to just restrict the X|Y construct to the isa constraint either.

This can be mitigated by splitting off the definition rules off from type constraints, but that would be its own undertaking.

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

2 participants