(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:
Alex Hall
2021-08-10 21:26:00 +02:00
parent 7f1f8fc9e6
commit ffeab944cc
2 changed files with 34 additions and 3 deletions

View File

@@ -301,8 +301,15 @@ class SummaryActions(object):
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.
group_args = ', '.join('%s=$%s' % (c.summarySourceCol.colId, c.colId)
for c in field_col_recs if c.summarySourceCol)
group_args = ', '.join(
'%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,
isFormula=True,
formula='%s.lookupRecords(%s)' % (source_table_id, group_args)))