typedb
typedb copied to clipboard
Defining player of inherited role actually results in playing the supertype relation's role
Description
As we know, when subtyping a relation, any roles that are not explicitly subtyped are implicitly inherited by the subtype:
define super_rel sub relation, relates super_rel_role, relates super_rel_role_2;
define sub_rel sub super_rel;
# sub_rel automatically inherits super_rel roles. They keep super_rel as their scope
So far so good.
But now, undefine sub_rel relates super_rel_role; should lead to an error since sub_rel has inherited super_rel_role.
However, what happens is equivalent to undefine super_rel relates super_rel_role, i.e. the role is undefined.
Environment
- OS (where TypeDB server runs): Mac OS 12.2.1
- TypeDB version (and platform): TypeDB 2.6.3
- TypeDB client: client-python, console
Reproducible Steps
See above.
Expected Output
Exception
Actual Output
The super_rel_role is undefined.
Very interesting! Does look like erroneous behaviour.
Edited example slightly: adds super_rel_role_2 to avoid raising unrelated exception due to undefining last role
Something very similar was spotted in the IAM schema. We declare the following:
action sub entity, abstract,
plays set-membership:member;
But in the TypeDB Studio, it says that action plays membership:member. The role member, as you might have guessed is inherited from the membership relation.
set-membership sub membership,
relates set as parent;
membership sub relation,
relates parent,
relates member;
@flyingsilverfin With the following schema:
define
person sub entity;
membership sub relation;
membership relates member;
club-membership sub membership;
person plays club-membership:member;
person instances can play the member role in both membership and club-membership instances. Querying:
match
$x plays $y;
returns:
{
$x type person sub entity;
$y type membership:member sub relation:role;
}
If I define person plays club-membership:member; then person should only be able to play member in instances of club-membership.