Skip to content

Query and grouped tables sort empty values first ascending; tag tables sort them last #1320

Closed
logseq/logseq
#13485

Description

@yuxi-liu-wired

Steps

  1. Create a tag Topic with a Date property "when".
  2. Tag 2 blocks with #Topic: "dated", with "when" set to any day, and "undated", without it.
  3. On the Topic page, sort the table by "when" ascending.
  4. Add a query block for (tags [[Topic]]), show it as a table, and sort it by "when" ascending.

Expected

Both tables list dated, then undated: a row with no value comes last in both directions, as on the tag page and as upstream's get-view-data-class-objects-missing-custom-sort-value-stays-last-test states.

Actual

The tag page lists dated, undated. The query table lists undated, dated. A tag page table grouped by any property also puts the rows with no value first within each group. The same holds for every property type, as soon as some rows lack the value.

Cause

get-view-data in deps/db/src/logseq/db/common/view.cljs sorts tag tables with sort-eids-by-sorting, whose compare-sort-values puts nil last in both directions. Query tables and grouped tables go through sort-entities, whose by-one-sorting calls compare, and compare puts nil first.

Found with a model-based property test of table views that compares the tag table with a query table over the same rows, replayed on upstream master 16c4ed1a0.

Activity

  1. yuxi-liu-wired commented on Oct 6, 2026

    @yuxi-liu-wired
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions