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 casting of type variables to value variables #329

Open
shreyas1599 opened this issue Apr 10, 2024 · 0 comments
Open

Allow casting of type variables to value variables #329

shreyas1599 opened this issue Apr 10, 2024 · 0 comments

Comments

@shreyas1599
Copy link

Problem to Solve

Currently, instance variables can be casted into value variables and the below query is valid.

match $entity isa entity-name has attribute-one $attributeOne;
?attributeValue = $attributeOne;
fetch nestedQuery: {
    match $anotherEntity is another-entity-name, has attribute-two ?attributeValue;
    fetch $anotherEntity: attribute;
};

But the same cannot be done with a type variable. For example, the below query is invalid. The below use case is to fetch the super types of an entity and then use a subquery to fetch another entity with an attribute filter that depends on the label of the supertype. Essentially, it's trying to cast a type variable into a value variable.

Query 1

match $someEntity isa $someEntityType, has id "some id";
$someEntityType sub entity;
not { $someEntityType sub someEntityType; };
?someEntityTypeValue = $someEntityType; # illegal operation
fetch $someEntityType;
metadataOfSomeEntity: {
    match $metadata isa metadata, has entity-type ?someEntityTypeValue;
    fetch $metadata: attribute;
};

Current Workaround

To run the aforementioned query, first get the labels of $someEntityType and then pass them into another query to run the sub query from above (metadataOfSomeEntity) either as a single query by using the OR operator or running them as separate queries for each of the labels.

Proposed Solution

To be able to run Query 1 without splitting it into >1 queries - support the casting of type variables to value variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant