-
Notifications
You must be signed in to change notification settings - Fork 49
Description
Here's the motivation for why links and link props need re-fetching on save.
Consider this schema:
module default {
type User {
multi link friends: default::User {
property nickname: std::str {
default := 'gang';
};
};
required property name: std::str {
constraint std::exclusive;
};
};
};
It is perfectly reasonable to write the following code:
a = default.User(name='Alice')
b = default.User(name='Billie', friends=[a])
db.save(b)
This should result in both objects a
and b
to be saved (because they are linked). Also, we explicitly added a
to b.friends
, and that was very much the point of what was being saved. So it would be surprising if after save
we would unset friends
. If we're fetching friends
, we should also fetch and reload its link props (especially since in this case there's a default value there).
Similarly, it would be odd if after saving either the links became unset or the link props became unset or invalid while the rest of the object gets updated/reloaded. The behaviour should be consistent regardless of whether save
creates or modifies an object.