mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Store formula values in DB, and include them into .stored/.undo fields of actions.
Summary: - Introduce a new SQLiteDB migration, which adds DB columns for formula columns - Newly added columns have the special ['P'] (pending) value in them (in order to show the usual "Loading..." on the first load that triggers the migration) - Calculated values are added to .stored/.undo fields of user actions. - Various changes made in the sandbox to include .stored/.undo in the right order. - OnDemand tables ignore stored formula columns, replacing them with special SQL as before - In particular, converting to OnDemand table leaves stale values in those columns, we should maybe clean those out. Some tweaks on the side: - Allow overriding chai assertion truncateThreshold with CHAI_TRUNCATE_THRESHOLD - Rebuild python automatically in watch mode Test Plan: Fixed various tests, updated some fixtures. Many python tests that check actions needed adjustments because actions moved from .stored to .undo. Some checks added to catch situations previously only caught in browser tests. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2645
This commit is contained in:
@@ -13,34 +13,6 @@ import logger
|
||||
log = logger.Logger(__name__, logger.INFO)
|
||||
|
||||
|
||||
class ColumnView(object):
|
||||
"""
|
||||
ColumnView is an iterable that represents one column of a RecordSet. You may iterate through
|
||||
its values and see its size, but it provides no other interface.
|
||||
"""
|
||||
def __init__(self, column_obj, row_ids, relation):
|
||||
self._column = column_obj
|
||||
self._row_ids = row_ids
|
||||
self._source_relation = relation
|
||||
|
||||
def __len__(self):
|
||||
return len(self._row_ids)
|
||||
|
||||
def __iter__(self):
|
||||
for row_id in self._row_ids:
|
||||
yield _adjust_record(self._source_relation, self._column.get_cell_value(row_id))
|
||||
|
||||
|
||||
def _adjust_record(relation, value):
|
||||
"""
|
||||
Helper to adjust a Record's source relation to be the composition with the given relation. This
|
||||
is used to wrap values like `foo.bar`: if `bar` is a Record, then its source relation should be
|
||||
the composition of the source relation of `foo` and the relation associated with `bar`.
|
||||
"""
|
||||
if isinstance(value, (records.Record, records.RecordSet)):
|
||||
return value._clone_with_relation(relation)
|
||||
return value
|
||||
|
||||
def _make_sample_record(table_id, col_objs):
|
||||
"""
|
||||
Helper to create a sample record for a table, used for auto-completions.
|
||||
@@ -468,7 +440,7 @@ class Table(object):
|
||||
|
||||
# Called when record.foo is accessed
|
||||
def _get_col_value(self, col_id, row_id, relation):
|
||||
return _adjust_record(relation,
|
||||
return records.adjust_record(relation,
|
||||
self._use_column(col_id, relation, [row_id]).get_cell_value(row_id))
|
||||
|
||||
def _attribute_error(self, col_id, relation):
|
||||
@@ -479,4 +451,4 @@ class Table(object):
|
||||
def _get_col_subset(self, col_id, row_ids, relation):
|
||||
# TODO: when column is a reference, we ought to return RecordSet. Otherwise ColumnView
|
||||
# looks like a RecordSet (returns Records), but doesn't support property access.
|
||||
return ColumnView(self._use_column(col_id, relation, row_ids), row_ids, relation)
|
||||
return records.ColumnView(self._use_column(col_id, relation, row_ids), row_ids, relation)
|
||||
|
||||
Reference in New Issue
Block a user