Delete attribute, bug or normal behavior?


Hi !

In our project we need to update attributes value. Sometimes the attribute is multivalued so we take the decision to remove all current values and then add the new value(s).

In order to do that we start to do this kind of query (to delete the field name)

match $m id V1234; $m has name $del; delete $del;

But with this query, we remove this attribute for every instances of the application for the specified value.
For example if we have
{ V1234 isa Malware, name: “test”}
{ V2345 isa Malware, name: “test”}
and do the query above, V1234 and V2345 will have the attribute name remove.

Base on the example we can find and the forum (How can I retrieve an instance and then update it with GRAQL?) we manage to make it work with this query:

match $m id V1234; $m has name $del via $rem; delete $rem;

But honestly match $m id V1234; $m has name $del; delete $del; seems to be a valid query :wink: It is a normal behavior to delete attribute that not match the initial condition?

Thanks !


Normal behaviour :slight_smile:

match $m id V1234; $m has name $del; delete $del is indeed a valid query and does what is expected of it, that is:
find the attributes with label name owned by thing with id of V1234 and delete them. It’s just that, the attribute being deleted here is owned also by V2345.

An Attribute with the same label and the same value exists only once in the knowledge graph.

What you really want to delete is the association that V1234 has with attribute name and that’s what the second query does:

match $m id V1234; $m has name $del via $rem; delete $rem;


Ok I understand. Thanks for the answer @soroush