Skip to content

fix(operators)!: name HasType in the has error message - #149

Open
pdevito3 wants to merge 1 commit into
mainfrom
fm/qk-breaking-has-message
Open

pdevito3 wants to merge 1 commit into
mainfrom
fm/qk-breaking-has-message

Conversation

@pdevito3

@pdevito3 pdevito3 commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

For later consideration in a major version. Do not merge now. #134 restored the v1.14.2 message to keep v1.x compatible (restore commit 22798f0). This PR re-applies the message of de350f7 (#109). The captain decides on this PR separately.

Summary

-            throw new QueryKitParsingException("DoesNotHaveType is only supported for collections");
+            throw new QueryKitParsingException("HasType is only supported for collections");

The change is in HasType in QueryKit/Operators/ComparisonOperator.cs only. The exception type does not change.

v1.14.2 behavior (and main)

The has operator (^$) on a property that is not a collection throws QueryKitParsingException with the message "DoesNotHaveType is only supported for collections". The message names the wrong operator.

New behavior

The same exception has the message "HasType is only supported for collections". The does-not-have operator (!^$) keeps its message "DoesNotHaveType is only supported for collections".

Example

FilterParser.ParseFilter<Recipe>("""Title ^$ "winner" """);
  • v1.14.2 and main: QueryKitParsingException: DoesNotHaveType is only supported for collections.
  • This PR: QueryKitParsingException: HasType is only supported for collections.

Justification

The message must name the operator that failed. The old message sends the user to the wrong operator.

Migration

If your code or your tests match the message text, change "DoesNotHaveType is only supported for collections" to "HasType is only supported for collections" for the has operator. Code that catches QueryKitParsingException by type does not change.

README

No change. The README does not document this message.

Tests

Unit FilterParserTests.has_type_on_non_collection_property_throws_the_v1_14_2_message becomes has_type_throws_correct_message_on_non_collection_property again, from main before #134. The expected message is "HasType is only supported for collections". No integration test changes.

dotnet test: 470 unit tests and 297 Postgres integration tests (Testcontainers) pass, 0 failures.

Rebase on main

This branch is rebased on current main (#169). The rebase had no conflicts. The breaking change did not change.

The has operator (^$) on a property that is not a collection threw the message of the does-not-have operator: "DoesNotHaveType is only supported for collections". Throw "HasType is only supported for collections" instead.

BREAKING CHANGE: the message of the QueryKitParsingException for has (^$) on a property that is not a collection changes from "DoesNotHaveType is only supported for collections" to "HasType is only supported for collections". Code that matches the old message text must match the new text.
@pdevito3
pdevito3 force-pushed the fm/qk-breaking-has-message branch from 9eb6bc8 to 1dd0e11 Compare October 1, 2026 21:49
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