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

Cleanup query mapping resolution of properties

Open
#3,620 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: task
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.