Use .custom_sql() for _group_count implementation (refs #150)

This commit is contained in:
Simon Willison 2018-04-08 08:42:56 -07:00
commit b2188f0442
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52

View file

@ -644,13 +644,12 @@ class TableView(RowTableShared):
# _group_count=col1&_group_count=col2
group_count = special_args_lists.get('_group_count') or []
if group_count:
count_sql = None
sql = 'select {group_cols}, count(*) as "count" from {table_name} {where} group by {group_cols} order by "count" desc limit 100'.format(
group_cols=', '.join('"{}"'.format(group_count_col) for group_count_col in group_count),
table_name=escape_sqlite(table),
where=where_clause,
)
is_view = True
return await self.custom_sql(request, name, hash, sql, editable=True)
else:
count_sql = 'select count(*) from {table_name} {where}'.format(
table_name=escape_sqlite(table),