Skip to content

Fix sort_by_popularity when hits is null#31

Open
excid3 wants to merge 2 commits intobiola:masterfrom
excid3:master
Open

Fix sort_by_popularity when hits is null#31
excid3 wants to merge 2 commits intobiola:masterfrom
excid3:master

Conversation

@excid3
Copy link
Copy Markdown

@excid3 excid3 commented Jan 21, 2021

Ran into this situation today:

If one record has no hits and another has X hits, they won't sort correctly. The record with no hits sorts first (at least in Postgres) no matter if it's sorted asc or desc because the SUM returns null.

Coalescing this to 0 fixed the sorting issue, but you could also do NULLS FIRST/LAST. I think both options are pretty well supported in sqlite, mysql, and postgres.

Also updated tests for this situation. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant