Conversation
v1.14.2 and main throw ArgumentException for an unknown property in arithmetic, also when AllowUnknownProperties is true. Arithmetic now uses the same unknown-property rules as other filter clauses. It throws UnknownFilterPropertyException, or it ignores the clause when unknown properties are allowed. Arithmetic supports only entity members. A query name, a derived property, or a custom operation name in arithmetic is unknown. BREAKING CHANGE: an unknown property in arithmetic throws UnknownFilterPropertyException, not ArgumentException. With AllowUnknownProperties, QueryKit ignores the arithmetic clause instead of throwing.
pdevito3
force-pushed
the
fm/qk-breaking-arithmetic-unknown
branch
from
October 1, 2026 21:39
0346f45 to
b875aaf
Compare
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.
For later consideration in a major version. Do not merge now. #134 restored the v1.14.2 behavior to keep v1.x compatible (restore commit
a3a4d54). This PR re-applies the behavior ofaf5c3f7(#113). The captain decides on this PR separately.Summary
An unknown property in an arithmetic clause gets the same result as an unknown property in any other filter clause:
AllowUnknownPropertiesisfalse(the default), QueryKit throwsUnknownFilterPropertyException.AllowUnknownPropertiesistrue, QueryKit ignores the clause.IgnoredClauseBehaviorcontrols the result, like for other ignored clauses.The changes:
QueryKit/FilterParser.cs: a newFindUnknownArithmeticSegmentwalks both sides of the arithmetic comparison before the parser builds the expression.QueryKit/PropertyResolver.cs:Resolvenow calls a newResolveWithoutDepthCheck, so arithmetic can resolve a property withoutMaxPropertyDepth. The result ofResolvedoes not change.v1.14.2 behavior (and main)
An unknown property in arithmetic throws
ArgumentException("Property 'Nope' not found on type 'TestingPerson'"). This also occurs whenAllowUnknownPropertiesistrue. A query name, a derived property, or a custom operation name in arithmetic also throwsArgumentException.New behavior
Arithmetic supports only entity members. A name that is not a member is unknown:
AllowUnknownProperties, the parser throwsUnknownFilterPropertyException("The filter property 'Nope' was not recognized.").AllowUnknownProperties, the parser ignores the clause.The check uses the same member lookup as other clauses. It does not apply
MaxPropertyDepth(item P, #138) orPreventFilter(item I, #136).Example
ArgumentException: Property 'Nope' not found on type 'TestingPerson'.x => (x.Age > 100).Without the configuration,
(Nope + 1) > 3throwsUnknownFilterPropertyExceptionon this PR.Justification
AllowUnknownPropertiesis documented as "unknown properties will be ignored". On v1.14.2, arithmetic ignores this setting. The README also says that an unknown filter property throwsUnknownFilterPropertyException. On v1.14.2, arithmetic throwsArgumentException, so an API that mapsQueryKitExceptionto a400returns a500for this input.Migration
ArgumentExceptionfor an unknown property in arithmetic, catchUnknownFilterPropertyException(orQueryKitException) instead.AllowUnknownProperties, an arithmetic clause on an unknown property no longer throws. QueryKit ignores the clause.README
The "Supported Features" list under "Arithmetic Expressions" gets one new item, "Unknown Properties". It states the exception, the
AllowUnknownPropertiesresult, and that arithmetic supports only entity members. The sections "Allow Unknown Properties" and "Error Handling" already describe the new behavior and do not change.Interaction with other PRs
ResolveWithoutDepthChecksplit and also edits the arithmeticSelect. If both merge, the second one gets a text conflict. The combined code is theResolveArithmeticPropertiesof main before fix: restore v1.14.2 behavior for every breaking change on main #134.ResolveArithmeticPropertieswith a depth check. The same text conflict occurs.query_name_in_arithmetic_throwschanges (see Tests).Tests
Unit (
QueryKit.UnitTests/PropertyResolverTests.cs), from main before #134:unknown_property_in_arithmetic_throws_when_unknown_properties_are_allowedbecomesunknown_property_in_arithmetic_removes_the_clause_when_unknown_properties_are_allowed.unknown_property_on_the_right_side_of_arithmetic_throws_when_unknown_properties_are_allowedbecomesunknown_property_on_the_right_side_of_arithmetic_removes_the_clause_when_unknown_properties_are_allowed.unknown_property_in_arithmetic_throws_an_argument_exceptionbecomesunknown_property_in_arithmetic_is_not_recognized.Unit, changed for this PR alone:
query_name_in_arithmetic_throwsbecomesquery_name_in_arithmetic_is_not_recognized. It expectsUnknownFilterPropertyExceptionfor(stars + 0) > 3, wherestarsis a query name. Main before fix: restore v1.14.2 behavior for every breaking change on main #134 resolved this query name (J-bis), so that test is not in this PR. If both PRs merge, keep the test of fix(filter)!: resolve query names in the grammar again #154: the query name resolves.Integration (
QueryKit.IntegrationTests/Tests/PropertyResolverTests.cs):unknown_property_in_arithmetic_removes_the_clause_when_unknown_properties_are_allowedcomes back.dotnet test: 470 unit tests and 298 Postgres integration tests (Testcontainers) pass, 0 failures.Rebase on main
This branch is rebased on current main. The only conflict was in the integration tests, where main added tests at the same place.