spring-projects / spring-projects/spring-data-mongodb
Cleanup query mapping resolution of properties
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
We have code like this that tries to resolve a PropertyPath multiple times doing the same/similar thing multiple times:
try {
if (entity.getPersistentProperty(path) != null) {
return PropertyPath.from(Pattern.quote(path), entity.getTypeInformation());
}
return PropertyPath.from(path, entity.getTypeInformation());
} catch (PropertyReferenceException | InvalidPersistentPropertyPath e) {
if (path.endsWith("_id")) {
return forName(path.substring(0, path.length() - 3) + "id");
}
// Ok give it another try quoting
try {
return PropertyPath.from(Pattern.quote(path), entity.getTypeInformation());
} catch (PropertyReferenceException | InvalidPersistentPropertyPath ex) {
}
return null;
}
We should revisit property resolution and simplify the code by avoiding duplications and refactoring it to a comprehensive form.
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.
Research direction
Start by locating the query-mapping property-resolution code represented by the issue's snippet and trace its callers. Review how PropertyPath, getPersistentProperty, and the _id fallback are used, then define a single comprehensive resolution path that preserves the required behavior without duplicated attempts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, mongodb
- Domain
- backend, databases
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100