typedb icon indicating copy to clipboard operation
typedb copied to clipboard

Disallow disconnected match queries

Open flyingsilverfin opened this issue 1 year ago • 2 comments

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.

flyingsilverfin avatar Jul 03 '23 16:07 flyingsilverfin

An example of the issues caused by currently allowing these queriesis seen at: https://github.com/vaticle/factory/pull/2262

flyingsilverfin avatar Jul 03 '23 16:07 flyingsilverfin

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.

james-whiteside avatar Jul 03 '23 17:07 james-whiteside