geldata / geldata/gel-python

Correctness of distinct list and dirty state tracking

Open
#759 0 comments 0 reactions 1 assignee Claimed by @1st1 View on GitHub
ORM
Dominant language
Python
Stars
415
Forks
50
PR merge metrics
No merged PRs in 30d

Description

We want the distinct lists to behave reasonably when created from scratch and when fetched from the database. Special care must be taken if the fetched data is incomplete or missing.

Basic ideas:

* `model.pointer = [ ... ]` ALWAYS means "replace with new data"
* `model.pointer.append(...)` ALWAYS translates into +=
* `model.pointer.remove(...)` ALWAYS translates into -=
* `model.pointer.clear()` only works when the collection is in *full-mode*.

There are two main modes of operation:
1) write-only mode: the collection allows `.append()` and `.remove()` operations. Its `__iter__`, `__len__`, `__contains__`, `__bool__` raise an error "cannot access unfetched data".
2) full-mode: the collection allows all operations on itself.

The full-mode is used when:
* the object is new (created from Python model)
* a field has been fully reset on an existing object, such as by assigning `[]`
* a field has been explicitly fetched and thus it has a known state

The write-only mode is used when:
* the object is initialized with an `id` (fetching an existing object of unknown state)
* some field has not been explicitly fetched, thus making its state unknown

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.