edgedb-js icon indicating copy to clipboard operation
edgedb-js copied to clipboard

Cardinality doesn't change for stored pointers

Open CarsonF opened this issue 1 year ago • 1 comments

Code The code causing the error.

const query = e.select(e.User, user => ({
  color: e.str('blue'),
  another: e.op(user.color, '??', 'blue'),
}));
type Out = Array<{
  color: string | null;
  another: string | null;
}>

Both of those use cases should result in a non-nullable string. EdgeQL correctly reports both of these cardinalities as One, so just QB thing.

Also using e.assert_exists() doesn't make a difference.

Schema

Your application schema.

module default {
  type User {
    optional color: str;
  }
}

Generated EdgeQL

Run the .toEdgeQL() method on your query and print the result. Then copy the generated query here.

Error or desired behavior

Copy/paste the error, or drag/drop a screenshot displaying the error message. If there's no error, describe the expected behavior.

Versions (please complete the following information):

  • OS:
  • EdgeDB version (e.g. 2.0):
  • EdgeDB CLI version (e.g. 2.0):
  • edgedb-js version (e.g. 0.20.10;):
  • @edgedb/generate version (e.g. 0.0.7;):
  • TypeScript version:
  • Node/Deno version:

CarsonF avatar Feb 08 '24 06:02 CarsonF

Here is the PR I made for fixing the first issue (cardinality of ??).

diksipav avatar Apr 17 '24 17:04 diksipav