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

Type error with custom bytes scalar in `filter: e.op(field, '=', literal)`

Open freeatnet opened this issue 3 years ago • 0 comments

Steps to reproduce:

  1. Define a custom scalar, scalar type sha512_output extending bytes.
  2. Define a field using that custom scalar, property file_sha512sum -> sha512_output
  3. Use the query builder to create a query that filters records based on the custom bytes scalar field, filter: e.op(movie.file_sha512sum, "=", e.sha512_output(aBuffer))

Expected: Query works as usual. Observed: Type error:

No overload matches this call.
  The last overload gave the following error.
    Argument of type '$expr_PathLeaf<getChildOfObjectTypeSet<{ __element__: $Movie; __cardinality__: Cardinality.One; __parent__: null; __kind__: ExpressionKind.PathNode; __exclusive__: true; "*": { id: true; genre: true; rating: true; release_year: true; title: true; file_sha512sum: true; }; }, "file_sha512sum">, { ...; }, false>' is not assignable to parameter of type 'orScalarLiteral<TypeSet<$str, Cardinality>>'.
      Type '$expr_PathLeaf<getChildOfObjectTypeSet<{ __element__: $Movie; __cardinality__: Cardinality.One; __parent__: null; __kind__: ExpressionKind.PathNode; __exclusive__: true; "*": { id: true; genre: true; rating: true; release_year: true; title: true; file_sha512sum: true; }; }, "file_sha512sum">, { ...; }, false>' is not assignable to type 'TypeSet<$str, Cardinality>'.
        Types of property '__element__' are incompatible.
          Type '$sha512_output' is not assignable to type '$str'.
            Type '"default::sha512_output"' is not assignable to type '"std::str"'.ts(2769)
operators.ts(4162, 10): The last overload is declared here.
operators.ts(4173, 10): The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible.

Here's a minimum repro using the test project: https://github.com/freeatnet/edgedb-js-repro/commit/a65fe0240bf13a9eff7c6ff6a762a6c963c7b3f5

freeatnet avatar May 18 '22 00:05 freeatnet