vaticle / typedb

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

Matching no types to the right from `isa` throws an error #7011

Open izmalk opened 3 months ago

izmalk commented 3 months ago

Description

When matching types, there can be a situation where no types are matched by the schema. Using a concept variable that matches no types as a type in an isa produces an error.

Environment

  1. TypeDB distribution: Core
  2. TypeDB version: 2.26.6
  3. Environment: macOS
  4. Client and version: Studio 2.26.0
  5. Other details:

Reproducible Steps

  1. Set up

Any schema with no @key annotations. The @key here is not of utmost importance, just a convenient way of matching no types.

  1. Execute
match
$f isa! $type;
$type owns $a @key;
get;
  1. Unexpected result
[QRY16] Invalid Query Pattern: Could not infer compatible types for the match pattern:
'{{ $type owns $a@@key; 
$f isa! $type; }}'.

Expected result

Empty collection (iterator/stream).

Additional information

Relevant logs from TypeDB or Driver:

14:32:11.725 [typedb-service::0] ERROR com.vaticle.typedb.core.server.TransactionService -- [QRY16] Invalid Query Pattern: Could not infer compatible types for the match pattern:
'{{ $type owns $a@@key;
$f isa! $type; }}'.

I'm not sure why @ is duplicated in the server logs.

flyingsilverfin commented 3 months ago

Makes sense. I've fixed the wrong toString for now!