vaticle / typedb

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

Disable using type information from IID in type inference #7016

Closed flyingsilverfin closed 3 months ago

flyingsilverfin commented 3 months ago

Usage and product changes

We decide to ignore IID information when performing type inference. This comes from the idea that IIDs are data, and the user may be trying to check whether the data conforms to a specific part of the schema. Previously, this will cause a query to throw an error due to type checking incompatibility, which made common expressions in fetch subqueries very difficult

Fetching stocks for books that are able to have stock (some subtypes of books do not have stock, such as 'ebook'):

match
$x isa book;
fetch:
stock: { 
  match $x isa! $t; $t owns stock;
  fetch $x: stock;
};

Which will retrieve stock for books, if the polymorphically selected book instance is able to own 'stock' attributes.

This expression now returns an empty list for instances of books that cannot own stocks instead of returning an error.

Implementation

vaticle-bot commented 3 months ago

PR Review Checklist

Do not edit the content of this comment. The PR reviewer should simply update this comment by ticking each review item below, as they get completed.


Trivial Change

Code

Architecture