Skip to content

fix(views): a missing value sorts last in query tables, both ways - #13610

Closed
yuxi-liu-wired wants to merge 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/table-filter-and-sort
Closed

yuxi-liu-wired wants to merge 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/table-filter-and-sort

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Updated: the "does not contain ignores case" half of this PR is now on master (93d19b6, #13487), so this PR keeps only the other half, rebased on master.

In query tables and grouped views (sort-entities), a row with no value for the sort property sorts first when sorting descending, and the order flips between directions; tag tables (sort-eids-by-sorting) already put such rows last both ways.

Cause: by-one-sorting and the minor sort (common-util/by-sorting) use compare, which puts nil first, and reverse it for descending.

Fix: compare-nil-last: nil last in both directions, otherwise compare in the sort's direction; used for the major sort and the minor sorts of sort-entities.

Test: logseq.db.common.view-test/sort-entities-puts-a-missing-value-last-both-ways-test: ascending, descending, and as the second sort key. On master the descending case fails; with the fix logseq.db.common.view-test passes (48 tests, 154 assertions, nbb). Lint as in CI for deps/db.

@yuxi-liu-wired yuxi-liu-wired changed the title fix(views): "does not contain" ignores case; a missing value sorts last in query tables fix(views): a missing value sorts last in query tables, both ways Oct 12, 2026
@yuxi-liu-wired
yuxi-liu-wired force-pushed the fix/table-filter-and-sort branch from 96e91be to 005b9ed Compare October 12, 2026 05:48
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Closing: master now has these fixes (#13485 missing sort values last, #13486 unchecked checkbox sorts as false, #13487 does-not-contain ignores case). This PR's tests pass on master 32570a6 without its code change.

@yuxi-liu-wired
yuxi-liu-wired deleted the fix/table-filter-and-sort branch October 21, 2026 18:02
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