Skip to content

Add isNull() to ComparisonOperators#5202

Open
sathish256 wants to merge 1 commit into
spring-projects:mainfrom
sathish256:issue/3473
Open

Add isNull() to ComparisonOperators#5202
sathish256 wants to merge 1 commit into
spring-projects:mainfrom
sathish256:issue/3473

Conversation

@sathish256

Copy link
Copy Markdown

Adds an additive isNull() builder to ComparisonOperators (and its Eq operator) so a field or expression can be compared to null in aggregation expressions:

ComparisonOperators.valueOf("qty").isNull(); // { $eq: [ "$qty", null ] }

This renders to the output requested in the issue and avoids the previous workaround of passing a null-returning expression (equalTo(ctx -> null)). The existing equalToValue(...) contract (which rejects null) is left unchanged.

A unit test is added in ProjectionOperationUnitTests (// GH-3473).

Closes #3473

Introduce an additive isNull() builder on ComparisonOperators and its Eq operator that renders to { $eq: [ <value>, null ] }. This lets users compare a field or expression to null without the previous workaround of passing a null-returning expression, while leaving the existing equalToValue(...) null-rejection contract unchanged.

Closes spring-projects#3473

Signed-off-by: sathish256 <17120479+sathish256@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ComparisonOperators should support isNull() [DATAMONGO-2619]

3 participants