Skip to content

Fix Query operators to reflect nullable parameters#8836

Merged
flobernd merged 1 commit intomainfrom
fix/8807-query-nullable-operators
Mar 5, 2026
Merged

Fix Query operators to reflect nullable parameters#8836
flobernd merged 1 commit intomainfrom
fix/8807-query-nullable-operators

Conversation

@amitkanfer
Copy link
Contributor

Summary

Fixes #8807

The &, |, !, and + operators on Query silently handle null arguments in their implementations, but the method signatures declared non-nullable parameters. This caused spurious CS8604 (possible null reference argument) warnings when combining Query? variables with these operators under nullable reference types.

Changes:

  • operator & and operator |: parameters changed from Query to Query?
  • And() and Or() internal helpers: parameters changed to Query?, non-null assertions added where the logic guarantees non-null after null checks
  • operator ! and operator +: return types changed to Query? to reflect they return null when the input is null

Test plan

  • Project compiles without CS8604 warnings when using Query? variables with & and |
  • null & query and query & null return the non-null operand (existing behavior preserved)
  • !((Query?)null) returns null (existing behavior preserved)
  • Existing tests pass

🤖 Generated with Claude Code

The &, |, !, and + operators on Query all handle null arguments,
but their signatures did not reflect this. Using a nullable Query?
variable with these operators caused CS8604 warnings under nullable
reference types.

Mark all operator parameters and return types appropriately with ?.

Fixes #8807

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cla-checker-service
Copy link

❌ Author of the following commits did not sign a Contributor Agreement:
bafbd33

Please, read and sign the above mentioned agreement if you want to contribute to this project

Copy link
Member

@flobernd flobernd left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you.

@flobernd flobernd merged commit 6fafe1a into main Mar 5, 2026
31 of 34 checks passed
@flobernd flobernd deleted the fix/8807-query-nullable-operators branch March 5, 2026 10:49
github-actions bot pushed a commit that referenced this pull request Mar 5, 2026
Co-authored-by: Amit Kanfer <amitkanfer@Amits-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 6fafe1a)
github-actions bot pushed a commit that referenced this pull request Mar 5, 2026
Co-authored-by: Amit Kanfer <amitkanfer@Amits-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 6fafe1a)
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

💚 All backports created successfully

Status Branch Result
8.19
9.3

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

flobernd pushed a commit that referenced this pull request Mar 5, 2026
)

Co-authored-by: Amit Kanfer <amit.kanfer@elastic.co>
Co-authored-by: Amit Kanfer <amitkanfer@Amits-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
flobernd pushed a commit that referenced this pull request Mar 5, 2026
Co-authored-by: Amit Kanfer <amit.kanfer@elastic.co>
Co-authored-by: Amit Kanfer <amitkanfer@Amits-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query operator handles null but no nullable in method siguature resulting in warnings

2 participants