mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Adding backend for 2-way references
Summary:
Adding support for 2-way references in data engine.
- Columns have an `reverseCol` field, which says "this is a reverse of the given column, update me when that one changes".
- At the time of setting `reverseCol`, we ensure that it's symmetrical to make a 2-way reference.
- Elsewhere we just implement syncing in one direction:
- When `reverseCol` is present, user code is generated with a type like `grist.ReferenceList("Tasks", reverse_of="Assignee")`
- On updating a ref column, we use `prepare_new_values()` method to generate corresponding updates to any column that's a reverse of it.
- The `prepare_new_values()` approach is extended to support this.
- We don't add (or remove) any mappings between rows, and rely on existing mappings (in a ref column's `_relation`) to create reverse updates.
NOTE This is polished version of https://phab.getgrist.com/D4307 with tests and 3 bug fixes
- Column transformation didn't work when transforming RefList to Ref, the reverse column became out of sync
- Tables with reverse columns couldn't be removed
- Setting json arrays to RefList didn't work if arrays contained other things besides ints
Those fixes are covered by new tests.
Test Plan: New tests
Reviewers: georgegevoian, paulfitz, dsagal
Reviewed By: georgegevoian, paulfitz
Subscribers: dsagal
Differential Revision: https://phab.getgrist.com/D4322
This commit is contained in:
@@ -831,7 +831,8 @@ function testDocApi() {
|
||||
visibleCol: 0,
|
||||
rules: null,
|
||||
recalcWhen: 0,
|
||||
recalcDeps: null
|
||||
recalcDeps: null,
|
||||
reverseCol: 0,
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -852,7 +853,8 @@ function testDocApi() {
|
||||
visibleCol: 0,
|
||||
rules: null,
|
||||
recalcWhen: 0,
|
||||
recalcDeps: null
|
||||
recalcDeps: null,
|
||||
reverseCol: 0,
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -873,7 +875,8 @@ function testDocApi() {
|
||||
visibleCol: 0,
|
||||
rules: null,
|
||||
recalcWhen: 0,
|
||||
recalcDeps: null
|
||||
recalcDeps: null,
|
||||
reverseCol: 0,
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -894,7 +897,8 @@ function testDocApi() {
|
||||
visibleCol: 0,
|
||||
rules: null,
|
||||
recalcWhen: 0,
|
||||
recalcDeps: null
|
||||
recalcDeps: null,
|
||||
reverseCol: 0,
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -915,7 +919,8 @@ function testDocApi() {
|
||||
visibleCol: 0,
|
||||
rules: null,
|
||||
recalcWhen: 0,
|
||||
recalcDeps: null
|
||||
recalcDeps: null,
|
||||
reverseCol: 0,
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1715,7 +1720,8 @@ function testDocApi() {
|
||||
"visibleCol": 0,
|
||||
"rules": null,
|
||||
"recalcWhen": 0,
|
||||
"recalcDeps": null
|
||||
"recalcDeps": null,
|
||||
reverseCol: 0,
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user