You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some users have reported that deleting or updating attributes is unintuitive. Currently, we can insert attributes without explicitly binding them to a variable, as follows:
insert
$p isa person,
has name "Josh",
has age 28;
However, when we want to delete attributes, we have to bind them to a variable:
match
$p isa person,
has name "Josh",
has age $a;
$a == 28;
delete
$p has $a;
insert
$p has age 29;
Proposed Solution
Given that a type and value are sufficient to identify an attribute instance, there is little need for the variable $a in this case. We could consider syntax of the following form instead:
match
$p isa person, has name "Josh";
delete
$p has age 28;
insert
$p has age 29;
What should happen if the attribute to be deleted does not exist is an open question. Most likely, this should not throw an error and the insert should still occur. This is in line with attribute deletion idempotency (typedb/typedb#6884).
This change will significantly simplify updates and deletes where only a single attribute must be changed. For cases where multiple attributes should be deleted, we can still use the "advanced" syntax where the attribute is "parametrised" in the delete clause:
match
$p isa person,
has name "Josh",
has nickname $n;
delete
$p has $n;
Note
The introduction of @replace in TypeDB 3.0 will simplify the case for updates, but not for deletes. This general change simplifies both, and makes @replace a syntactic sugar. These two methods for updates will have slightly different behaviour, and there may be some more nuanced cases where one syntax is preferable to the other for updates. As such, both should be permitted.
The text was updated successfully, but these errors were encountered:
Problem to Solve
Some users have reported that deleting or updating attributes is unintuitive. Currently, we can insert attributes without explicitly binding them to a variable, as follows:
However, when we want to delete attributes, we have to bind them to a variable:
Proposed Solution
Given that a type and value are sufficient to identify an attribute instance, there is little need for the variable
$a
in this case. We could consider syntax of the following form instead:What should happen if the attribute to be deleted does not exist is an open question. Most likely, this should not throw an error and the insert should still occur. This is in line with attribute deletion idempotency (typedb/typedb#6884).
This change will significantly simplify updates and deletes where only a single attribute must be changed. For cases where multiple attributes should be deleted, we can still use the "advanced" syntax where the attribute is "parametrised" in the delete clause:
Note
The introduction of
@replace
in TypeDB 3.0 will simplify the case for updates, but not for deletes. This general change simplifies both, and makes@replace
a syntactic sugar. These two methods for updates will have slightly different behaviour, and there may be some more nuanced cases where one syntax is preferable to the other for updates. As such, both should be permitted.The text was updated successfully, but these errors were encountered: