mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Use .custom_sql() for _group_count implementation (refs #150)
This commit is contained in:
parent
446d47fdb0
commit
b2188f0442
1 changed files with 1 additions and 2 deletions
|
|
@ -644,13 +644,12 @@ class TableView(RowTableShared):
|
||||||
# _group_count=col1&_group_count=col2
|
# _group_count=col1&_group_count=col2
|
||||||
group_count = special_args_lists.get('_group_count') or []
|
group_count = special_args_lists.get('_group_count') or []
|
||||||
if group_count:
|
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(
|
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),
|
group_cols=', '.join('"{}"'.format(group_count_col) for group_count_col in group_count),
|
||||||
table_name=escape_sqlite(table),
|
table_name=escape_sqlite(table),
|
||||||
where=where_clause,
|
where=where_clause,
|
||||||
)
|
)
|
||||||
is_view = True
|
return await self.custom_sql(request, name, hash, sql, editable=True)
|
||||||
else:
|
else:
|
||||||
count_sql = 'select count(*) from {table_name} {where}'.format(
|
count_sql = 'select count(*) from {table_name} {where}'.format(
|
||||||
table_name=escape_sqlite(table),
|
table_name=escape_sqlite(table),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue