Skip to content

Commit

Permalink
Don't use aliases to avoid clash with columns named 'value'
Browse files Browse the repository at this point in the history
Fixes #2208
  • Loading branch information
rgieseke committed Nov 15, 2023
1 parent 0fe5b3b commit b5a58b6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions datasette/facets.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ async def suggest(self):
if column in already_enabled:
continue
suggested_facet_sql = """
select {column} as value, count(*) as n from (
select {column}, count(*) from (
{sql}
) where value is not null
group by value
) where {column} is not null
group by {column}
limit {limit}
""".format(
column=escape_sqlite(column), sql=self.sql, limit=facet_size + 1
Expand All @@ -188,7 +188,7 @@ async def suggest(self):
1 < num_distinct_values < row_count
and num_distinct_values <= facet_size
# And at least one has n > 1
and any(r["n"] > 1 for r in distinct_values)
and any(r["count(*)"] > 1 for r in distinct_values)
):
suggested_facets.append(
{
Expand Down

0 comments on commit b5a58b6

Please sign in to comment.