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

Missing parameter machinery for MultiRange input types

Open scotttrinh opened this issue 4 months ago • 1 comments

We do not currently support building a parameterized query with MultiRange input types.

    const query = e.params(
      { in_range: e.multirange(e.datetime) },
      (params) => {
        return e.select(
          e.op(e.datetime_current(), ">", params.in_range)
        );
      }
    );

Gives the type error:

Type 'multirangeλFuncExpr<TypeSet<ArrayType<RangeType<$anypoint, "range<std::number>" | "range<cal::local_date>" | "range<std::datetime>" | "range<std::duration>" | "range<std::decimal>" | "range<cal::local_datetime>">, "array<range<std::number>>" | ... 4 more ... | "array<range<cal::local_datetime>>">, Cardinality>>' is not assignable to type 'Param'.
  Type 'multirangeλFuncExpr<TypeSet<ArrayType<RangeType<$anypoint, "range<std::number>" | "range<cal::local_date>" | "range<std::datetime>" | "range<std::duration>" | "range<std::decimal>" | "range<cal::local_datetime>">, "array<range<std::number>>" | ... 4 more ... | "array<range<cal::local_datetime>>">, Cardinality>>' is not assignable to type 'ScalarType<string, any, any, any> | EnumType<string, [string, ...string[]]> | TupleType<tupleOf<ParamType>> | NamedTupleType<{ [k: string]: ParamType; }>'.
    Property '__shape__' is missing in type 'multirangeλFuncExpr<TypeSet<ArrayType<RangeType<$anypoint, "range<std::number>" | "range<cal::local_date>" | "range<std::datetime>" | "range<std::duration>" | "range<std::decimal>" | "range<cal::local_datetime>">, "array<range<std::number>>" | ... 4 more ... | "array<range<cal::local_datetime>>">, Cardinality>>' but required in type 'NamedTupleType<{ [k: string]: ParamType; }>'.

scotttrinh avatar Jul 29 '25 13:07 scotttrinh

Doing a little bit of poking around, it looks like we need to do some special casing for MultiRange in a similar way we have for Range:

  • https://github.com/geldata/gel-js/blob/master/packages/generate/src/syntax/range.ts
  • https://github.com/geldata/gel-js/blob/be91c704b27f269af18caa4e70e44d9d70eb64aa/packages/generate/src/edgeql-js/generateFunctionTypes.ts#L109-L113

scotttrinh avatar Jul 29 '25 14:07 scotttrinh