vaticle / typedb

TypeDB: the polymorphic database powered by types
https://typedb.com
Mozilla Public License 2.0
3.73k stars 338 forks source link

Multiple IID negations return concepts with negated ids #6471

Closed flyingsilverfin closed 2 years ago

flyingsilverfin commented 2 years ago

Description

Including two negations of IIDs will return answers that includes one of those IIDs, even though they should have been excluded by the negation.

Environment

Any platform TypeDB 2.5.0

Reproducible Steps

Schema:

define
  person sub entity, owns name;
  name sub attribute, value string;

insert data:

insert
  $x isa person, has name "bob";
  $y isa person, has name "alice";
  $z isa person, has name "catherine";

try the following queries:

> match $x isa person; not { $x iid <bob's iid> }; not { $x iid <alice's iid>; };
... returns all people excluding BOB

The same happens when going through reasoning.

Expected Output

Alice and Bob should have been excluded in the answer, only returning the person with name Catherine.

Actual Output

Returns all people only excluding Bob.

Additional information

  1. This occurs in both reasoning and non-reasoning
  2. it may extend to non-IID negations
  3. querying the following:
    match $x isa person; not { {$x iid <bob's iid>; } or { $x iid <alice's iid>;};};

    succeeds as expected!

FrankUrbach commented 2 years ago

Another query which leads to unexpected behavior is:

match 
$x sub thing;
not {$x type thing;};
not {$x type entity;};
not {$x type attribute;};
not {$x type relation;};
offset 0;
limit 1000;

Here thing, entity, attribute and relation shouldn't be visible.

flyingsilverfin commented 2 years ago

Fixed with #6483