geldata / geldata/gel-python

Refetching links and link props on save

Open
#844 0 comments 0 reactions 0 assignees View on GitHub
low priority ORM
Dominant language
Python
Stars
415
Forks
50
PR merge metrics
No merged PRs in 30d

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.