File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
typeql-reference/modules/ROOT/pages/statements Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,41 @@ match $person isa person;
3939insert $person has name "Alice";
4040----
4141
42+ If the value is a variable instead of a literal, you must use `==`.
43+
44+ [,typeql]
45+ ----
46+ #!test[write]
47+ #{{
48+ match
49+ $person isa person;
50+ #}}
51+ match let $name_value = "Alice";
52+ insert $person has name == $name_value;
53+ ----
54+ [NOTE]
55+ ====
56+ Writing `insert $person has name $name_value;` will result in an error:
57+ "_The variable 'name_value' cannot be declared as both a 'Attribute' and as a 'Value'._ "
58+
59+
60+ This is best understood by rewriting syntactic short-hands into atomic constraints.
61+
62+ `$p has name $n;` *becomes* `$p has $n; $n isa T;` .
63+
64+ `$p has T == $n;` *becomes* `$p has $_a; $_a isa T; $_a == $n;`
65+
66+ In the first case, `$n` is clearly an attribute. The
67+ second case, introduces a new variable `$_a` as the attribute and requires its value to be the same as that of $n.
68+
69+ The confusion arises from being able to write ``$p has name "Alice;"`` . But:
70+
71+ `$p has name "Alice;"` *becomes* `$p has T == "Alice";`
72+
73+ This is syntax-sugar introduced *ONLY* for literals, and is rewritten further as above.
74+ ====
75+
76+
4277== Deleting attribute ownership
4378
4479The `has` keyword is used to remove an attribute from its owner.
You can’t perform that action at this time.
0 commit comments