1

I'm using edgedb with python.

My db scheme is

type Student {
    link class -> Class {
        on target delete allow;
    };
};
type Class {
    required property year -> int32;
    required property name -> str;
}

I'm running query like this

with student_to_update := (
    select Student {
        id,
        class: {
            id,
            name,
            year
        }
    }
    filter .id = <uuid>$student_id
    )
update student_to_update
set {class := (select Class filter .id = <uuid>$class_id)};

I got an error modification of computed link 'class' of object type 'default::Student' is prohibited.

Probably it something related to backlinks, but in my schema link is direct.

cottontail
  • 10,268
  • 18
  • 50
  • 51

2 Answers2

1

This looks like a bug. I opened an issue for it here https://github.com/edgedb/edgedb/issues/4346

To work around this, remove the shape from the select in the with block.

with
    student_to_update := (select Student filter .id = <uuid>$student_id),
    updated := (update student_to_update set {
        class := (select Class filter .id = <uuid>$class_id),
    }),
select updated {
    id,
    class: {
        id,
        name,
        year
    }
};
fmoor
  • 349
  • 2
  • 8
0

This appears to be a bug associated with including an unnecessary shape on the select Student query. When you get rid of the shape this query works as expected.

with student_to_update := (
  select Student
  filter .id = <uuid>$student_id
)
update student_to_update
set {class := (select Class filter .id = <uuid>$class_id)};

As a general rule, your shape should be defined on the outermost "layer" of your query. So if you want to fetch properties on the updated objects, you'd do something like this:

with student_to_update := (
  select Student
  filter .id = <uuid>$student_id
)
select (
  update Student
  filter .id = <uuid>$student_id
  set {
    class := (select Class filter .id = <uuid>$class_id)
}) {
  id,
  class: {
    id,
    name,
    year
  }
};

The fact that your original query fails is still a bug though.

Colin McDonnell
  • 897
  • 1
  • 11
  • 17