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

Introducing `required` tuple results in layered errors

Open jackfischer opened this issue 2 years ago • 2 comments

  • EdgeDB Version: 3.3
  • EdgeDB CLI Version: 3.5.0+e1ad387
  • OS Version: macos 13.5

Steps to Reproduce:

  1. Add required tuple property to a type
type Example {
    required someTuple: tuple<a: str, b: str>;
}
  1. Migration produces the following prompt with strange std|str syntax
did you create property 'someTuple' of object type 'default::Example'? [y,n,l,c,b,s,q,?]
> y
Please specify an expression to populate existing objects in order to make property 'someTuple' of object type 'default::Example' required:
fill_expr> <tuple<a:std|str, b:std|str>>{}
  1. Change the set to be a tuple, error appears inline
fill_expr> <tuple<a:std|str, b:std|str>>(a:="a_", b:="b_")1:17: token "," is not allowed in expression (try parenthesize the expression)
  1. Add parens as suggested, different error
fill_expr> (<tuple<a:std|str, b:std|str>>(a:="a_", b:="b_"))
error: InvalidReferenceError: type 'default::std' does not exist
  ┌─ <statement>:3:22
  │
3 │         SET REQUIRED USING ((<tuple<a:std|str, b:std|str>>(a:="a_", b:="b_")));
  │                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean '.id'?

Rolling back last operation...

Workaround is to just put in the tuple directly. Filing for 1) the friction here and 2) in case it's a hint of a deeper CLI or compiler problem.

fill_expr> (a:="a_", b:="b_")

jackfischer avatar Sep 14 '23 16:09 jackfischer

Just to chime in I had the same issue when removing a field from a named tuple:

Please specify a conversion expression to alter the type of property 'emoji':
cast_expr_2> <tuple<id:std|str, name:std|str, native:std|str>>.emoji

Rewrote to (.mytuple.id,.mytuple.name,.mytuple.native) to just rely on the fact that tuples are still ordered.

nervetattoo avatar Oct 18 '23 19:10 nervetattoo

Also confirmed on 4.x (EdgeDB 4.2+833dd8d (repl 4.0.2+500be79))

jackfischer avatar Nov 17 '23 16:11 jackfischer