edgedb / edgedb

A graph-relational database with declarative schema, built-in migration system, and a next-generation query language
https://edgedb.com
Apache License 2.0
12.83k stars 393 forks source link

Cardinality of polymorphic shape field isn't optional #6254

Closed jackfischer closed 9 months ago

jackfischer commented 10 months ago

Describe the bug Polymorphic EdgeQL query where a string field may not be present is inferred as string

Reproduction Schema

type Message {}
type SlackMultiUserMessage extending Message {
  slackDisplayName: str;
}

edgeql query file

select Message {
  *,
  [is SlackMultiUserMessage].slackDisplayName
}

Generated TS

export type TestReturns = {
  "slackDisplayName": string;
  "id": string;
}[];

Expected behavior slackDisplayName would be optional.

Versions (please complete the following information):

scotttrinh commented 10 months ago

Thanks for reporting @jackfischer

It's unclear if this is a bug in the queries generator, or a subtle bug in the cardinality inference in EdgeDB itself. I'll see if I can get to the bottom of that.

jackfischer commented 10 months ago

Totally. Not aware of a great way to examine this on the CLI side so filed here for now.

msullivan commented 9 months ago

It is a bug in edgedb's card inference