edgedb-js
edgedb-js copied to clipboard
`e.op(optional, "??", required)` cardinality
Follow up from discord
Code The code causing the error.
name: e.op(a.optionalProperty, "??", a.requiredProperty),
Schema
Your application schema.
type A {
optionalProperty: str;
required requiredProperty: str;
}
Generated EdgeQL
...
SELECT __scope_1_defaultOrganization {
name := (__scope_1_defaultA.optionalProperty ?? __scope_1_defaultA.requiredProperty)
}
...
Run the .toEdgeQL() method on your query and print the result. Then copy the generated query here.
Error or desired behavior
name infers to string | null instead of the expected string.
Versions (please complete the following information):
- OS: macos 13
- EdgeDB version (e.g.
2.0): 3.0 - EdgeDB CLI version (e.g.
2.0): 3.3.0+3f6a0a0 edgedb-jsversion (e.g.0.20.10;): 1.3.2@edgedb/generateversion (e.g.0.0.7;): 0.3.0- Typescript version: 5.1.6
- Node/Deno version:
I'd like to call out too a type's declared property cannot override cardinality when computing like this. i.e. @jackfischer example above is different than
optionalProperty: e.op(a.optionalProperty, "??", a.requiredProperty),
But it would be great if both inferred the correct cardinality to TS.