Skip to content

Commit

Permalink
Fix linkprop card issuee (#439)
Browse files Browse the repository at this point in the history
* Fix linkprop card issuee

* 0.22.3

* Fix card in scopify
  • Loading branch information
colinhacks authored Sep 5, 2022
1 parent dd25635 commit eefc05f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down
13 changes: 8 additions & 5 deletions qb/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
14 changes: 14 additions & 0 deletions qb/test/select.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ({
Expand Down
7 changes: 1 addition & 6 deletions src/reflection/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ export type $linkPropify<Root extends ObjectTypeSet> = Root extends {
any,
any
>
? pathifyLinkProps<
// tslint:disable-next-line
LinkProps,
Root,
PathParent<Parent, L>
>
? pathifyLinkProps<LinkProps, Root, PathParent<Parent, L>>
: {}
: unknown;

Expand Down
7 changes: 6 additions & 1 deletion src/syntax/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,12 @@ export function select<
>(
expr: Expr,
shape: (
scope: $scopify<Expr["__element__"]> & $linkPropify<Expr>
scope: $scopify<Expr["__element__"]> &
$linkPropify<{
[k in keyof Expr]: k extends "__cardinality__"
? Cardinality.One
: Expr[k];
}>
) => Readonly<Shape>
): $expr_Select<{
__element__: ObjectType<
Expand Down

0 comments on commit eefc05f

Please sign in to comment.