Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making overloaded link required and subtyped in "grandchild" of inherited type breaks query builder #592

Open
Arrow7000 opened this issue May 6, 2023 · 0 comments · May be fixed by #606
Labels

Comments

@Arrow7000
Copy link

Code

e.insert(e.StrategyGamer, {
    faveGame: strategyGame,
//  ^^^^^^^^^^^^^^^^^^^^^^ link `faveGame` is not allowed even though it should be
    firstName: "A",
    lastName: "A",
});

Schema

abstract type Game {
    # ...
}
type FpsGame extending Game {
    # ...
}
type StrategyGame extending Game {
    # ...
}

abstract type Person {
    link faveGame -> Game; # 👈 optional link
    required property firstName -> str;
    required property lastName -> str;
}
abstract type Gamer extending Person {
    # ...
}
type StrategyGamer extending Gamer {
    overloaded required link faveGame -> StrategyGame; # 👈 overloaded link, required and specialised subtype
}

Generated EdgeQL

The EdgeQL does generate correctly. It's just TS which isn't happy with it.

INSERT default::StrategyGamer {
  faveGame := (
    INSERT default::StrategyGame {
      # ...
    }
  ),
  firstName := "A",
  lastName := "A"
}

Error or desired behavior

faveGame is not an allowed property when trying to insert a new StrategyGamer. But not only should it be allowed - because StrategyGamer extends Person which has a link faveGame -> Game - but it should actually be required; since StrategyGamer overloads the link to make it required + more specialised.

This bug only seems to happen when the overloaded link is both required and refers to a subtype, but not when only one of those two changes are made.

There is no faveGame in the allowed insert query fields, not even optional
image

But inserting a new Gamer - i.e. a direct inheritor of Person where faveGame is defined - does correctly know about faveGame
image

Versions (please complete the following information):

  • OS: Windows 10 Home build 19045.2846
  • EdgeDB version (e.g. 2.0): 2.13+c171f92
  • EdgeDB CLI version (e.g. 2.0): 2.3.1+ef99779
  • edgedb-js version (e.g. 0.20.10;):
  • @edgedb/generate version (e.g. 0.0.7;): 0.1.0
  • Typescript version: 5.0.4
  • Node/Deno version: Node v18.15.0
@scotttrinh scotttrinh added the bug label May 8, 2023
@scotttrinh scotttrinh linked a pull request May 17, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants