Is there a way to get the entities with all the attributes in one query?

Hey team,

I’m struggling to get all the relations with attributes and without them in one query. Now it looks like I really need two:
match $x sub relation; , match $x sub relation; $x owns $attr; and union them in the client code.

Is there an expression to do it in one query or is this a language limitation for now?

Wouldn’t match $x sub relation; return both relations with and without attributes?

I’d expect:
match $x sub relation; $x owns $attr; to return only those with attributes.
match $x sub relation; not {$x owns $attr;}; to return only those with attributes.

Wouldn’t match $x sub relation; return both relations with and without attributes?

Yes it would, but it won’t return any attributes at all. Speaking about union I meant that you should union list of all the relations and list of relations with attributes.

E.g.:

  • rel1
  • rel2
  • rel3
    UNION
  • rel1 owns name, date

Right now a match query always returns a “fixed size” of answers that is returned. As such, we don’t currently support returning one answer that contains a relation $x and another answer that contains $x and $attr
With the proposed introduction of optionals this kind of thing will be possible: Allow retrieving attributes optionally, without filtering the query · Issue #6322 · vaticle/typedb · GitHub