Skip to content

Commit

Permalink
Add failing test for discriminated unions from polymorphic queries vi…
Browse files Browse the repository at this point in the history
…a type intersection expr
  • Loading branch information
CarsonF committed Sep 4, 2024
1 parent 3c1439c commit b9eff07
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
4 changes: 3 additions & 1 deletion integration-tests/lts/dbschema/default.esdl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ module default {

type Hero extending Person {
property secret_identity -> str;
property number_of_movies -> int64;
required property number_of_movies -> int64 {
default := 0;
};
multi link villains := .<nemesis[IS Villain];
}

Expand Down
10 changes: 10 additions & 0 deletions integration-tests/lts/dbschema/migrations/00028-m1cigpn.edgeql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE MIGRATION m1cigpnllpzucl3lckxtsfnozf6zbyagfakqal7ejkc3sd2ocj4efa
ONTO m173ddshjvgy5ampp7rzi2g7cwwdkaljvlifemr5vugnkimtbpp6ca
{
ALTER TYPE default::Hero {
ALTER PROPERTY number_of_movies {
SET default := 0;
SET REQUIRED USING (0);
};
};
};
29 changes: 29 additions & 0 deletions integration-tests/lts/select.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,35 @@ SELECT __scope_0_defaultPerson {
);
});

test.skip("polymorphic from type intersection", async () => {
const query = e.select(e.Movie.characters, (person) => ({
heroMovieCount: person.is(e.Hero).number_of_movies,
heroInfo: e.select(person.is(e.Hero), (hero) => ({
number_of_movies: true,
numMovies: hero.number_of_movies,
})),
}));
type result = $infer<typeof query>;
tc.assert<
tc.IsExact<
result,
(
| {
__typename: "default::Villain";
}
| {
__typename: "default::Hero";
heroMovieCount: number;
heroInfo: {
number_of_movies: number;
numMovies: number;
};
}
)[]
>
>(false);
});

test("polymorphic field in nested shape", async () => {
const query = e.select(e.Movie, (movie) => ({
title: true,
Expand Down

0 comments on commit b9eff07

Please sign in to comment.