Open hbriese opened 1 year ago
We should be inferring the same cardinality as the EdgeQL compiler, which is the real bug here. We detect the cardinality of the query here as ONE
(based on the use of filter_single
), but for some reason the database is indicating that the cardinality ought to be MANY
, and since we use querySingle
on queries that we think ought to be EMPTY
, ONE
, and AT_MOST_ONE
, we throw this error at query time.
It feels like the query ought to have a cardinality of ONE
, so the real question here is why the server is responding with a MANY
cardinality option here: is it a bug? If it is indeed MANY
, we ought to detect this in the filter_single
case and (ideally) make it a TypeScript compile-time error instead of a runtime error.
When selecting a link that was selected in
filter_single
you get aResultCardinalityMismatchError: the query has cardinality MANY which does not match the expected cardinality ONE
error.Copying the edgeql query (i.e.
.toEdgeQL()
) and executing it directly does not error, so the issue appears to be with the query builder.The query looks silly, but makes more sense when selecting the account initially from another exclusive constraint, or when the query is constructed from something like graphql
Code
Schema
Error or desired behavior
Workaround
Using
e.assert_single
andfilter
doesn't suffer from this issueVersions (please complete the following information):
2.0
):3.2+bb17a05
(same error in 3.1)2.0
):3.4.0+160d07d
edgedb-js
version (e.g.0.20.10
;):1.3.4
@edgedb/generate
version (e.g.0.0.7
;):0.3.1
5.1.3
18.12.1