question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider adding type expression syntax to exclude or explicitly include subtypes

See original GitHub issue

On queries over type Foo EdgeDB will include both Foo objects and all objects of its descendant types. EdgeQL currently lacks a way to turn off automatic inclusion of inherited objects (a-la the SQL ONLY keyword). There is a way to filter over the exact value of .__type__, but that is neither elegant, nor very efficient if spelled in a most concise way (FILTER .__type__.name = 'default::BaseType').

ONLY seems to be a good candidate for a modifier in a particular case of excluding all descendants.

By nature the ONLY operator (and its tentative EXCEPT counterpart) are type expression operators similar to the type union | and intersection &, so perhaps #1578 should be implemented first to avoid the tedium of repeating the inheritance op, e.g WITH MyType AS TYPE Foo ONLY or WITH MyType AS TYPE Foo EXCEPT Subtype. Also, perhaps EXCEPT should be - or ^ to be closer to other type operators.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
elpranscommented, Jul 29, 2020

So if ONLY is a type expression operator then “select specifically Foo” would be SELECT Foo[IS ONLY Foo], right?

Correct, although I’m thinking a postfix form would be better.

0reactions
dmgolembiowskicommented, Sep 29, 2020

Depends on where it would be placed.

ONLY is semantically a type expression operator, unlike DETACHED, which is an expression operator that manipulates scope.

This is an interesting idea — especially since it fits the EdgeDB niche where “everything is a set”.
From my perspective, [IS ONLY] could be an implementation derived from creating disjoint unions, and could even play an interesting role with the :- operator since the disjoint union of A and B boils down to A − B.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript 2.0
Null- and undefined-aware types. TypeScript has two special types, Null and Undefined, that have the values null and undefined respectively.
Read more >
Why is forall a. a not considered a subtype of Int while I can ...
I.e. an expression of type forall a. a can be used where one of type Int is expected. This seems to me a...
Read more >
Common issues and solutions - mypy 0.991 documentation
Covariant subtyping of mutable protocol members is rejected​​ Mypy rejects this because this is potentially unsafe. Consider this example: from typing_extensions ...
Read more >
What's new in TypeScript
If an explicit type annotation is added, e.g. static defaultProps: Partial<Props>; the compiler will not be able to identify which properties have defaults ......
Read more >
The Go Programming Language Specification
Explicit conversions are required when different numeric types are mixed in an expression or assignment. For instance, int32 and int are not the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found