Skip to content

Commit

Permalink
Use .custom_sql() for _group_count implementation (refs #150)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Apr 8, 2018
1 parent 446d47f commit b2188f0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,12 @@ async def data(self, request, name, hash, table):
# _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),
Expand Down

0 comments on commit b2188f0

Please sign in to comment.