spring-projects / spring-projects/spring-data-mongodb

Improve usage experience of `AggregationExpression` factories

Open
#4,474 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

SetOperators, DateOperators and other factories to create aggregation expressions accept either String field references or AggregationExpressions.

With the evolution of AggregationVariable, that is a Field, calling code has to unwrap the variable target:

SetUnion.arrayAsSet(Variable.VALUE.getTarget()).union(Variable.THIS.getTarget())

It would be much nicer to drop getTarget and simply use Variable.VALUE/Variable.THIS:

SetUnion.arrayAsSet(Variable.VALUE).union(Variable.THIS)

One approach to achieve this could be accepting Field/Field... in places where we accept a String field reference.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the factory signatures in SetOperators, DateOperators, and other AggregationExpression factories, focusing on where String field references and AggregationExpression values are accepted. Review AggregationVariable and Field usage to determine the relevant overloads. Done means callers can pass Variable.VALUE or Variable.THIS directly instead of calling getTarget, with the affected aggregation behavior covered by the project’s existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mongodb
Domain
backend-api-design, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.