hn.today

Replacing implicit optionals with a None type in TypeDB

typedb.com6 points0 comments
Screenshot of Replacing implicit optionals with a None type in TypeDB

TypeDB distinguishes missing data from stored nulls: entities, relations, and attributes are never stored as “absent”; instead, a query may leave a variable unset when a pattern has no match. Since version 3.4, optional matching has allowed one query to return both companies with office addresses and those without them. Initially, however, using an optional variable implicitly discarded rows where it was empty. That convenience could silently change a query’s results, and offered no way to branch on whether a value was missing. Unlike SQL’s nulls and three-valued logic, TypeDB models emptiness as a typed None value, which can appear alongside ordinary types in a variable’s type union.

TypeDB 3.15 replaces implicit handling with explicit checks so that optionality must be addressed wherever it affects results. The system now warns about deprecated uses, including patterns that silently exclude rows. In read patterns, an isset constraint lets queries require that an optional variable has a value; expressions can use question-mark short-circuiting to propagate emptiness rather than treating it as an ordinary value. Conditional operators in write clauses allow updates to take different actions depending on whether a variable is set, addressing cases that previously could not be expressed cleanly. The change aims to make query behavior more predictable, catch mistakes earlier, and support more composable reads and updates.

Read on typedb.com0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.