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

Consider disallowing primitive booleans for undefined keys in object shape

Open scotttrinh opened this issue 4 months ago • 1 comments

A query like this:

const q = e.select(e.User, () => ({
  name: true,
  birthdaet: true,
}));

Will type-check (and run) successfully since it treats the typo birthdaet as a computed with the value true. While this is a supported use case, it's rarely an intentional one. If you intend to set a computed to the literal true or false value, the safer way is to use e.bool(true) and e.bool(false) instead of relying on the automatic primitive up-casting in this case.

It seems somewhat controversial to make a big breaking change like this when it's hard to tell the intent of the caller, making it hard to find out if you're accidentally relying on this behavior. Maybe we can hide this behind a --future-no-primitive-computeds flag and fail for any computed that uses a primitive? Or special case this as --future-no-boolean-computeds?

scotttrinh avatar Jun 03 '25 13:06 scotttrinh