diff --git a/package.json b/package.json index 4688ca99d..159b7bf4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edgedb", - "version": "0.22.2", + "version": "0.22.3", "description": "The official Node.js client library for EdgeDB", "homepage": "https://edgedb.com/docs", "author": "EdgeDB ", diff --git a/qb/playground.ts b/qb/playground.ts index d9c4b719c..22d5f6fa6 100644 --- a/qb/playground.ts +++ b/qb/playground.ts @@ -8,11 +8,14 @@ async function run() { console.log(`~~~~~~~~~~~~~~~~~~~~~~~~~~~`); // const query = e.for(e.Bag, bag => {}); - const query = e.select(e.Movie, movie => ({ - id: true, - title: true, - filter: e.op(movie.genre, "=", e.Genre.Action), - })); + + const query = e.select(e.Movie.characters, c => { + console.log(c["@character_name"].__cardinality__); + return { + name: true, + // ["@character_name"]: true, + }; + }); console.log(query.toEdgeQL()); const result = await query.run(client); console.log(JSON.stringify(result, null, 2)); diff --git a/qb/test/select.test.ts b/qb/test/select.test.ts index 8072bb4c1..9a00cb057 100644 --- a/qb/test/select.test.ts +++ b/qb/test/select.test.ts @@ -1193,6 +1193,20 @@ test("filter on link prop in nested path", async () => { await query.run(client); }); +test("cardinality of linkprop in scopified object", async () => { + const query = e.select(e.Movie.characters, c => { + expect(c["@character_name"].__cardinality__).toEqual( + $.Cardinality.AtMostOne + ); + return { + name: true, + // doesn't work yet + // ["@character_name"]: true, + }; + }); + await query.run(client); +}); + // EdgeQL limitation // test("link prop on backlink", async()=>{ // const query = e.select(e.Person, person => ({ diff --git a/src/reflection/path.ts b/src/reflection/path.ts index c25f3ade1..07a698ee0 100644 --- a/src/reflection/path.ts +++ b/src/reflection/path.ts @@ -48,12 +48,7 @@ export type $linkPropify = Root extends { any, any > - ? pathifyLinkProps< - // tslint:disable-next-line - LinkProps, - Root, - PathParent - > + ? pathifyLinkProps> : {} : unknown; diff --git a/src/syntax/select.ts b/src/syntax/select.ts index 1aacea374..f3b5f0fe0 100644 --- a/src/syntax/select.ts +++ b/src/syntax/select.ts @@ -706,7 +706,12 @@ export function select< >( expr: Expr, shape: ( - scope: $scopify & $linkPropify + scope: $scopify & + $linkPropify<{ + [k in keyof Expr]: k extends "__cardinality__" + ? Cardinality.One + : Expr[k]; + }> ) => Readonly ): $expr_Select<{ __element__: ObjectType<