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

Generated exclusive types are not accurate when using `constraint exclusive on` syntax for a single attribute

Open Karavil opened this issue 2 years ago • 1 comments

Code The code causing the error.

e.select(e.Example, () => ({
  filter_single: {name: 'Iron Man'}
}));

Schema

Your application schema.

module default {
  type Example {
    required property name -> str;
    constraint exclusive on (.name);
  }
}

The above TS filter_single logic works at runtime, but throws a TS error. If we modify the schema to be:

module default {
  type Example {
    required property name -> str {
       constraint exclusive;
    }
  }
}

then the type error is fixed (and runtime logic is unchanged).

Karavil avatar Jul 04 '23 18:07 Karavil

Here's the associated Discord thread https://discord.com/channels/841451783728529451/849377751370432573/1125534997021986896

Karavil avatar Jul 04 '23 18:07 Karavil