Skip to content

fix(views): table filters keep working when a clause is empty or matches text values - #13884

Closed
yuxi-liu-wired wants to merge 3 commits into
logseq:masterfrom
yuxi-liu-wired:fix/dbtest-1434
Closed

yuxi-liu-wired wants to merge 3 commits into
logseq:masterfrom
yuxi-liu-wired:fix/dbtest-1434

Conversation

@yuxi-liu-wired

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

Copy link
Copy Markdown
Contributor

Fixes logseq/db-test#1434, fixes logseq/db-test#1392, fixes logseq/db-test#1054.

Three table view filter bugs, one commit each.

What the user sees

  • Click the Advanced Queries block and don't jump to the target.  #1434: On All Pages, a Tags filter set to "Empty" crashes the page with "Invalid view resource context" as soon as the operator is switched between "is" and "is not". The broken filter is saved on the view, so the page keeps failing until the filter is removed.
  • 无法保存文件 #1392: Changing a Text filter from "is" to "text contains" (or "text not contains") replaces the table with "Invalid view resource context" before a search string can be typed. The error stays after a reload.
  • feat: upgrade some dependencies #1054: In a query table, a grouped table or a linked-references table, a filter such as "Author is Smith" on a text property shows only one of the blocks whose Author is Smith. The same filter in a tag's table, or with the clause added a second time, shows all of them.

Cause

  • Click the Advanced Queries block and don't jump to the target.  #1434: When the operator changes, view-filter-value-after-operator-change (src/main/frontend/worker/handler/view.cljs) kept the value for :is and :is-not only when it was a set. The Empty choice is stored as the keyword :empty, so it was dropped and the two-element clause [:block/tags :is] was saved.
  • 无法保存文件 #1392: A clause without a value is the normal state of a filter whose value has not been entered yet: changing the operator clears the old values, persistence drops a nil value on purpose (table-filters->persist-state), the editor creates [property :text-contains] for a new Text filter, and both filter matchers (row-matched? and eid-clause-match?) treat a clause without a value as matching every row. Only valid-filters? in src/main/frontend/worker/handler/render_resource/view.cljs required exactly three elements, so it rejected a clause the rest of the code accepts. The clause is therefore valid and the validation was wrong, and the code that builds clauses is unchanged. Click the Advanced Queries block and don't jump to the target.  #1434 is a separate bug in which a value that should have been kept was lost, so it is fixed where the clause is built.
  • feat: upgrade some dependencies #1054: Every block stores its text in its own value block, and the filter's value list keeps one entry per distinct text. For a single :is or :is-not clause on a ref property, build-fast-filter-pred (deps/db/src/logseq/db/common/view.cljs) compared value block ids, so only the block whose value block was listed matched. row-matched? compares the text for such values, which is why a second clause gave the expected rows. Properties with choices share one value block per choice and were not affected.

Change

  • Click the Advanced Queries block and don't jump to the target.  #1434: view-filter-value-after-operator-change also keeps :empty for :is and :is-not.
  • 无法保存文件 #1392: valid-filters? accepts clauses with two or three elements. A clause of any other length is still rejected, and the worker already reports that as the view's error message (isolated-view-failure) instead of failing the whole snapshot. Views that already have such a clause saved render again without being edited.
  • feat: upgrade some dependencies #1054: build-fast-filter-pred makes the same choice as row-matched?: a value that is not matched as an entity (match-property-value-as-entity?) is compared by its content instead of its id.

Tests

  • Click the Advanced Queries block and don't jump to the target.  #1434: view-filter-data-keeps-empty-value-when-switching-is-and-is-not (src/test/frontend/worker/handler/view_test.cljs). Fails without the fix (2 failures), passes with it.
  • 无法保存文件 #1392: view-data-resource-accepts-filter-clauses-without-a-value-test (src/test/frontend/worker/handler/render_resource_test.cljs). Requests a view with two valueless clauses and expects no error and the clauses passed to the view query; also checks that clauses with one or four elements are still an isolated view error. Fails without the fix (2 failures in render-resource-test, 95 tests), passes with it, and the whole main-bundle suite passes.
  • feat: upgrade some dependencies #1054: get-view-data-query-result-is-filter-matches-equal-text-in-separate-value-blocks-test (deps/db/test/logseq/db/common/view_test.cljs). Filters a query table on the text of one of two blocks with the same text. Without the fix :is returns one of the two blocks and :is-not returns the other matching block (2 failures); with it :is returns both and :is-not returns only the block with different text. The whole deps/db suite passes (201 tests, 766 assertions).

Devin Review

…d is not

On a table view such as All Pages, a filter set to "Tags is Empty" crashed the page with "Invalid view resource context" as soon as the operator was switched between "is" and "is not". The broken filter was saved on the view, so the page kept crashing until the filter was removed.

When the operator changes, the worker decides which value the filter keeps. For "is" and "is not" it kept the value only if it was a set, but the Empty choice is stored as the keyword :empty, so it was dropped. The UI then saved a two-element clause such as [:block/tags :is], which view resource validation rejects.

view-filter-value-after-operator-change now also keeps :empty for "is" and "is not". The views.cljs call site already passes the current value and stores what the worker returns, so it needs no change.

Added view-filter-data-keeps-empty-value-when-switching-is-and-is-not, which checks that :empty survives a switch to :is and :is-not and is still dropped for an operator that cannot use it (:text-contains).

Fixes logseq/db-test#1434
…th a single is clause

In a query table, a grouped table or a linked-references table, a filter such as "Author is Smith" on a text property showed only one of the blocks whose Author is Smith. The same filter in a tag's table, or with the clause added a second time, showed all of them.

Every block stores its text in its own value block, and the filter's value list keeps one entry per distinct text. For a single is or is-not clause on a ref property, build-fast-filter-pred compared the ids of the value blocks, so only the block whose value block was listed matched. row-matched? compares the text in this case, which is why a second clause gave the expected rows. Properties with choices share one value block per choice and were not affected.

build-fast-filter-pred now makes the same choice as row-matched?: a value that is not matched as an entity is compared by its content instead of its id.

Added get-view-data-query-result-is-filter-matches-equal-text-in-separate-value-blocks-test, which filters a query table on the text of one of two blocks that have the same text and expects both, and the other block for is-not.

Fixes logseq/db-test#1054
On a table view, changing a Text filter from "is" to "text contains" (or "text not contains") replaced the table with "Invalid view resource context" before a search string could be typed. The incomplete clause was saved on the view, so the error stayed after a reload.

When the operator changes, the old selected values are cleared and the clause is saved as [property operator], and the filter editor produces the same two-element clause for a newly added Text filter. Persistence also drops a nil value on purpose, and both filter matchers treat a clause without a value as matching every row. Only the view resource context validation required exactly three elements, so it rejected a clause the rest of the code accepts.

The validation now accepts clauses with two or three elements. A clause of any other length is still rejected and is reported as the view's error message instead of failing the whole snapshot. Views that already have such a clause saved render again without being edited.

Added view-data-resource-accepts-filter-clauses-without-a-value-test, which requests a view with two valueless clauses and expects no error and the clauses passed to the view query, and checks that clauses with one or four elements are still reported as an isolated view error.

Fixes logseq/db-test#1392

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Combined into #13885 with the other PRs of this theme, to keep the number of open PRs down; the commits are unchanged there.

@yuxi-liu-wired
yuxi-liu-wired deleted the fix/dbtest-1434 branch November 17, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant