Skip to content

fix(filter)!: ignore a fully prevented clause by its query name - #152

Merged
pdevito3 merged 1 commit into
v2from
fm/qk-breaking-prevented-query-name
Oct 3, 2026
Merged

pdevito3 merged 1 commit into
v2from
fm/qk-breaking-prevented-query-name

Conversation

@pdevito3

@pdevito3 pdevito3 commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • QueryKitPropertyMappings.ReplaceAliasesWithPropertyPaths no longer throws InvalidOperationException for the query name of a property with PreventFilter() and PreventSort(). It replaces the query name like any other query name.
  • On v2, fix(filter)!: resolve query names in the grammar again #154 already deleted the call of this check from ParseFilter. A filter that uses the query name of a fully prevented property removes the clause (or replaces it with true == true), like any prevented property.

v1.14.2 behavior

With HasQueryName("name").PreventFilter().PreventSort() on Title:

Input v1.14.2 This PR on v2
name == "x" || Age > 100 InvalidOperationException: 'Title' is not allowed for filtering or sorting. x => (x.Age > 100)
Title == "name == x" (query name name on FirstName) InvalidOperationException, because the regex matched text inside the quoted value x => (x.Title == "name == x")
ReplaceAliasesWithPropertyPaths("name == \"x\"") InvalidOperationException Title == "x"

Justification

A prevented property must act the same way in every form: the clause is ignored by IgnoredClauseBehavior. The throw applied only when both settings were on, only in front of an operator, and also inside quoted values.

Migration

If a client caught InvalidOperationException for this case, it now gets the result of the other clauses.

Tests

  • Unit PropertyResolverTests: query_name_of_a_property_prevented_for_filter_and_sort_in_a_quoted_value_is_not_changed and alias_replacement_does_not_throw_for_a_property_prevented_for_filter_and_sort.
  • Integration (Postgres): prevented_property_clause_by_its_query_name_under_or_does_not_return_every_row.
  • dotnet test: 529 unit tests and 325 Postgres integration tests pass.

@pdevito3
pdevito3 force-pushed the fm/qk-breaking-prevented-query-name branch from 694f31e to eaf0d0e Compare October 1, 2026 21:40
@pdevito3
pdevito3 changed the base branch from main to v2 October 3, 2026 11:55
v1.14.2 and main throw InvalidOperationException when a filter uses the query name of a property with PreventFilter and PreventSort. The member name of the same property gives an ignored clause. The alias rewrite pass no longer throws, so the query name gives the same ignored clause as the member name.

BREAKING CHANGE: a filter clause on the query name of a property with PreventFilter and PreventSort no longer throws InvalidOperationException. IgnoredClauseBehavior controls the clause, like for the member name. QueryKitPropertyMappings.ReplaceAliasesWithPropertyPaths no longer throws for this query name.
@pdevito3
pdevito3 force-pushed the fm/qk-breaking-prevented-query-name branch from eaf0d0e to 16349da Compare October 3, 2026 11:57
@pdevito3
pdevito3 merged commit bebdd06 into v2 Oct 3, 2026
2 checks passed
@pdevito3
pdevito3 deleted the fm/qk-breaking-prevented-query-name branch October 3, 2026 11:58
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