edgedb icon indicating copy to clipboard operation
edgedb copied to clipboard

Confusing `modification of computed property` error message on repeated property on insert

Open jackfischer opened this issue 2 years ago • 5 comments

  • EdgeDB Version: 3.5 and 4.1+0c628ea
  • EdgeDB CLI Version: 4.0.2+500be79
  • OS Version: macos 13

Steps to Reproduce:

  1. Run the following (clearly wrong) query insert Example {prop:=datetime_current(), prop:=datetime_current()};
error: QueryError: modification of computed property 'prop' of object type 'default::Example' is prohibited
  ┌─ <query>:1:43
  │
1 │ insert Example {prop:=datetime_current(), prop:=datetime_current()};
  │                                           ^^^^^^^^^^^^^^^^^^^^^^^^ error

Of course in this example it's easy to see what's wrong with the query, but in the much more complicated example we discovered this in, it was pretty bewildering. Also filing not just for UX but in case it is a hint of any more concerning underlying problem.

Schema:

type Example {
    property prop: datetime;
}

jackfischer avatar Nov 15 '23 15:11 jackfischer

I would like to see this say something about defining the computed property twice or maybe redefining the computed prop. Seems like that would be clearer. A couple of suggestions that might work:

  • redefining the computed property 'prop' of object type 'default::Example' is prohibited
  • you may not define the computed property 'prop' of object type 'default::Example' more than once

I think I'd lean toward the latter option out of those two.

raddevon avatar Nov 15 '23 17:11 raddevon

The big item is that this isn't a computed property at all. Just realized this is must just be how inserts are implemented, but suffice to say users don't think of the expressions they're assigning to properties in an insert as computed.

jackfischer avatar Nov 15 '23 18:11 jackfischer

Perhaps it's coming up as computed because of the datetime_current function. However, it's also confusing to call it a "modification". The original query we noticed this in was an upsert which was extra confusing. I'm accustomed to minimizing the queries for bug reports but in this case that actually contributes to the central problem here which is the confusing nature of the message.

jackfischer avatar Nov 17 '23 01:11 jackfischer

The big item is that this isn't a computed property at all.

Oh, right. This is an insert. 🤦‍♂️ Forget my suggestions then. Maybe this instead:

  • you may not assign the property 'prop' of object type 'default::Example' more than once

or something along those lines.

raddevon avatar Nov 17 '23 13:11 raddevon

Another way this crops up: forgetting to not define a shape after turning a select into a with,

with gpt4users := (select
   User {preferredFoundationModel: {provider_model_identifier}}
filter .preferredFoundationModel.provider_model_identifier like "gpt-4%"
),

update gpt4users set {
  preferredFoundationModel := (select FoundationModel filter .provider_model_identifier = "gpt-4-turbo")
}

jackfischer avatar Apr 12 '24 18:04 jackfischer