Repository navigation
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
Closed
yuxi-liu-wired wants to merge 3 commits into
yuxi-liu-wired wants to merge 3 commits into
Conversation
…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
This was referenced Oct 27, 2026
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Cause
view-filter-value-after-operator-change(src/main/frontend/worker/handler/view.cljs) kept the value for:isand:is-notonly 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.table-filters->persist-state), the editor creates[property :text-contains]for a new Text filter, and both filter matchers (row-matched?andeid-clause-match?) treat a clause without a value as matching every row. Onlyvalid-filters?insrc/main/frontend/worker/handler/render_resource/view.cljsrequired 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.:isor:is-notclause 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
view-filter-value-after-operator-changealso keeps:emptyfor:isand:is-not.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.build-fast-filter-predmakes the same choice asrow-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
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.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 inrender-resource-test, 95 tests), passes with it, and the whole main-bundle suite passes.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:isreturns one of the two blocks and:is-notreturns the other matching block (2 failures); with it:isreturns both and:is-notreturns only the block with different text. The wholedeps/dbsuite passes (201 tests, 766 assertions).