mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) A few tiny documentation tweaks.
Summary: - Improve readability of documentation of CONTAINS. - Add leading underscore to Record._get_encodable_row_ids() to hide from public docs, and avoid interfering with user fields. - Fix up lint errors Test Plan: No behavior changes Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3209
This commit is contained in:
parent
596bd194d5
commit
b37b8a9f6d
@ -154,7 +154,9 @@ def VLOOKUP(table, **field_value_pairs):
|
||||
class _Contains(namedtuple("_Contains", "value")):
|
||||
"""
|
||||
Use this marker with [UserTable.lookupRecords](#lookuprecords) to find records
|
||||
where a field of a list type (such as `Choice List` or `Reference List`) contains the given value, e.g:
|
||||
where a field of a list type (such as `Choice List` or `Reference List`) contains the given value.
|
||||
|
||||
For example:
|
||||
|
||||
MoviesTable.lookupRecords(genre=CONTAINS("Drama"))
|
||||
|
||||
|
@ -612,6 +612,8 @@ def ROUND(value, places=0):
|
||||
2.0
|
||||
>>> ROUND(2.5)
|
||||
3.0
|
||||
>>> ROUND(-2.5)
|
||||
-3.0
|
||||
>>> ROUND(2.15, 1)
|
||||
2.2
|
||||
>>> ROUND(-1.475, 2)
|
||||
|
@ -190,7 +190,7 @@ def encode_object(value):
|
||||
elif isinstance(value, (list, tuple)):
|
||||
return ['L'] + [encode_object(item) for item in value]
|
||||
elif isinstance(value, records.RecordSet):
|
||||
return ['r', value._table.table_id, value.get_encodable_row_ids()]
|
||||
return ['r', value._table.table_id, value._get_encodable_row_ids()]
|
||||
elif isinstance(value, RecordSetStub):
|
||||
return ['r', value.table_id, value.row_ids]
|
||||
elif isinstance(value, dict):
|
||||
|
@ -133,6 +133,8 @@ class RecordSet(object):
|
||||
|
||||
You can get the number of records in a RecordSet using `len`, e.g. `len($group)`.
|
||||
"""
|
||||
# Methods should be named with a leading underscore to avoid interfering with access to
|
||||
# user-defined fields.
|
||||
def __init__(self, table, row_ids, relation=None, group_by=None, sort_by=None):
|
||||
"""
|
||||
group_by may be a dictionary mapping column names to values that are all the same for the given
|
||||
@ -194,7 +196,7 @@ class RecordSet(object):
|
||||
group_by=self._group_by,
|
||||
sort_by=self._sort_by)
|
||||
|
||||
def get_encodable_row_ids(self):
|
||||
def _get_encodable_row_ids(self):
|
||||
"""
|
||||
Returns stored rowIds as a simple list or tuple type, even if actually stored as RecordList.
|
||||
"""
|
||||
|
@ -89,9 +89,10 @@ class UserTable(object):
|
||||
```
|
||||
|
||||
See [RecordSet](#recordset) for useful properties offered by the returned object.
|
||||
|
||||
See [CONTAINS](#contains) for an example utilizing `UserTable.lookupRecords` to find records where
|
||||
a field of a list type (such as `Choice List` or `Reference List`) contains the given value.
|
||||
|
||||
See [CONTAINS](#contains) for an example utilizing `UserTable.lookupRecords` to find records
|
||||
where a field of a list type (such as `Choice List` or `Reference List`) contains the given
|
||||
value.
|
||||
"""
|
||||
return self.table.lookup_records(**field_value_pairs)
|
||||
|
||||
@ -356,6 +357,7 @@ class Table(object):
|
||||
col_id = summary_table._summary_helper_col_id
|
||||
if self.has_column(col_id):
|
||||
# If type changed between Reference/ReferenceList, replace completely.
|
||||
# pylint: disable=unidiomatic-typecheck
|
||||
if type(self.get_column(col_id).type_obj) != type(_updateSummary.grist_type):
|
||||
self.delete_column(self.get_column(col_id))
|
||||
col_obj = self._create_or_update_col(col_id, _updateSummary)
|
||||
|
Loading…
Reference in New Issue
Block a user