mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Fix detaching summary tables grouped by list column
Summary: Detached formula uses CONTAINS() Test Plan: Added to existing unit test Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2972
This commit is contained in:
parent
7f1f8fc9e6
commit
ffeab944cc
@ -301,8 +301,15 @@ class SummaryActions(object):
|
|||||||
col_info = [_make_col_info(col=c) for c in field_col_recs if c.colId != 'group']
|
col_info = [_make_col_info(col=c) for c in field_col_recs if c.colId != 'group']
|
||||||
|
|
||||||
# Prepare the 'group' column, which is that one column that's different from the original.
|
# Prepare the 'group' column, which is that one column that's different from the original.
|
||||||
group_args = ', '.join('%s=$%s' % (c.summarySourceCol.colId, c.colId)
|
group_args = ', '.join(
|
||||||
for c in field_col_recs if c.summarySourceCol)
|
'%s=%s' % (
|
||||||
|
c.summarySourceCol.colId,
|
||||||
|
'CONTAINS($%s)' % c.colId
|
||||||
|
if c.summarySourceCol.type.startswith(('ChoiceList', 'RefList:')) else
|
||||||
|
'$%s' % c.colId,
|
||||||
|
)
|
||||||
|
for c in field_col_recs if c.summarySourceCol
|
||||||
|
)
|
||||||
col_info.append(_make_col_info(colId='group', type='RefList:%s' % source_table_id,
|
col_info.append(_make_col_info(colId='group', type='RefList:%s' % source_table_id,
|
||||||
isFormula=True,
|
isFormula=True,
|
||||||
formula='%s.lookupRecords(%s)' % (source_table_id, group_args)))
|
formula='%s.lookupRecords(%s)' % (source_table_id, group_args)))
|
||||||
|
@ -257,11 +257,35 @@ class TestSummaryChoiceList(EngineTestCase):
|
|||||||
[2, "b", [102, 103, 105, 106, 108, 109], 6],
|
[2, "b", [102, 103, 105, 106, 108, 109], 6],
|
||||||
])
|
])
|
||||||
|
|
||||||
self.assertTableData('GristSummary_6_Source2', data=[
|
summary_data = [
|
||||||
["id", "choices1", "choices2", "group", "count"],
|
["id", "choices1", "choices2", "group", "count"],
|
||||||
[1, "a", "c", [101, 103, 107, 109], 4],
|
[1, "a", "c", [101, 103, 107, 109], 4],
|
||||||
[2, "a", "d", [104, 106, 107, 109], 4],
|
[2, "a", "d", [104, 106, 107, 109], 4],
|
||||||
[3, "b", "c", [102, 103, 108, 109], 4],
|
[3, "b", "c", [102, 103, 108, 109], 4],
|
||||||
[4, "b", "d", [105, 106, 108, 109], 4],
|
[4, "b", "d", [105, 106, 108, 109], 4],
|
||||||
[5, "a", "e", [], 0],
|
[5, "a", "e", [], 0],
|
||||||
|
]
|
||||||
|
|
||||||
|
self.assertTableData('GristSummary_6_Source2', data=summary_data)
|
||||||
|
|
||||||
|
# Verify that "DetachSummaryViewSection" useraction works correctly.
|
||||||
|
self.apply_user_action(["DetachSummaryViewSection", 2])
|
||||||
|
|
||||||
|
self.assertTables([
|
||||||
|
self.starting_table, summary_table1, summary_table3, summary_table4,
|
||||||
|
Table(
|
||||||
|
6, "Table1", primaryViewId=5, summarySourceTable=0,
|
||||||
|
columns=[
|
||||||
|
Column(27, "manualSort", "ManualSortPos", isFormula=False, formula="", summarySourceCol=0),
|
||||||
|
Column(28, "choices1", "Choice", isFormula=False, formula="", summarySourceCol=0),
|
||||||
|
Column(29, "choices2", "Choice", isFormula=False, formula="", summarySourceCol=0),
|
||||||
|
Column(30, "count", "Int", isFormula=True, summarySourceCol=0,
|
||||||
|
formula="len($group)"),
|
||||||
|
Column(31, "group", "RefList:Source", isFormula=True, summarySourceCol=0,
|
||||||
|
formula="Source.lookupRecords(choices1=CONTAINS($choices1), choices2=CONTAINS($choices2))"),
|
||||||
|
|
||||||
|
],
|
||||||
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
self.assertTableData('Table1', data=summary_data, cols="subset")
|
||||||
|
Loading…
Reference in New Issue
Block a user