spring-projects / spring-projects/spring-data-mongodb
ComparisonOperators.Lte seems to match undefined/null value in switch caseOperator
Open
@christophstrobl is already working on this.
Since Aug 30, 2021.
status: ideal-for-contribution
type: enhancement
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
ComparisonOperators.Lte seems to match undefined/null value in switch caseOperator
reactiveMongoTemplate.upsert(Query.query(
Criteria.where("id").is(b.getId())
), AggregationUpdate.update()
.set("field.value").toValue(
ConditionalOperators.switchCases(
CaseOperator.when(Gte.valueOf("field_priority")
.greaterThanEqualToValue(b.getField().getPriority()))
.then("gte"),
CaseOperator.when(Lte.valueOf("field_priority")
.lessThanEqualToValue(b.getField().getPriority()))
.then("lt")
)
.defaultTo("default")
), Bar.class)).flatMap(c -> Mono.just(foo));
if there is no document in the database we expect to run the default case, however we see the lte case is being ran.
We've tried fiddling with the order and gt, lt methods but none of them seem to accomplish what we're after.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.