mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
More reliable tie-break ordering for facet results
I was seeing a weird bug where the order of results running tests on my laptop was inconsistent, causing pytest failures even though the order of tests in Travis CI was fine. I think the fix is to explicitly state how facet ordering ties on the count should be resolved.
This commit is contained in:
parent
298a899e79
commit
0091dfe3e5
1 changed files with 3 additions and 3 deletions
|
|
@ -198,7 +198,7 @@ class ColumnFacet(Facet):
|
|||
{sql}
|
||||
)
|
||||
where {col} is not null
|
||||
group by {col} order by count desc limit {limit}
|
||||
group by {col} order by count desc, value limit {limit}
|
||||
""".format(
|
||||
col=escape_sqlite(column), sql=self.sql, limit=facet_size + 1
|
||||
)
|
||||
|
|
@ -344,7 +344,7 @@ class ArrayFacet(Facet):
|
|||
select j.value as value, count(*) as count from (
|
||||
{sql}
|
||||
) join json_each({col}) j
|
||||
group by j.value order by count desc limit {limit}
|
||||
group by j.value order by count desc, value limit {limit}
|
||||
""".format(
|
||||
col=escape_sqlite(column), sql=self.sql, limit=facet_size + 1
|
||||
)
|
||||
|
|
@ -457,7 +457,7 @@ class DateFacet(Facet):
|
|||
{sql}
|
||||
)
|
||||
where date({col}) is not null
|
||||
group by date({col}) order by count desc limit {limit}
|
||||
group by date({col}) order by count desc, value limit {limit}
|
||||
""".format(
|
||||
col=escape_sqlite(column), sql=self.sql, limit=facet_size + 1
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue