typedb
typedb copied to clipboard
Disallow disconnected match queries
Problem to Solve
We should disallow disconnected match queries, since these are usually user errors. In particular, when combined with data writes such as deletes, a 'match' query generating more data than it is expected leads to over-eager deletion.
Proposed Solution
Throw an exception when the user writes disconnected portions of a 'match' queries.
An example of the issues caused by currently allowing these queriesis seen at: https://github.com/vaticle/factory/pull/2262
As discussed, this would be banned by this approach:
match
$x isa person, has name "x";
$y isa person, has name "y";
insert
(friend: $x, friend: $y) isa friendship;
In fact any query that finds two disconnected patterns and join them would be banned. Maybe we could allow disconnected patterns if each one includes at least one value-bound attribute? Haven't given it much thought so might not be viable either.