spring-projects / spring-projects/spring-data-commons

Defect in QueryDSLBindings class while updating local field pathSpecs for ListPath [DATACMNS-1302]

Open
#1,744 2 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 30, 2020.

in: repository type: bug
Dominant language
Java
Stars
838
Forks
730
PR merge metrics
No merged PRs in 30d

Description

GT opened DATACMNS-1302 and commented

The method in question is below in QuerydslBindings class -

{{^private static String fromRootPath(Path<?> path) {

	Path<?> rootPath = path.getMetadata().getRootPath();

	if (rootPath == null) {
		throw new IllegalStateException(String.format("Couldn't find root path on path %s!", path));
	}

	return path.toString().substring(rootPath.getMetadata().getName().length() + 1);
}^}}

Let's say I have customized bindings for 3 paths for root object QUser with root name in generated metadata as "user":

  • user.userName
  • user.profile.internalSystemID
  • user.emails.any().value which gets internally translated as any(user.emails).value

When bindings are updated locally in pathSpecs, the logic in above method simply tries to strip the root object path name and following DOT, so in this case it ends up storing following 3 entries:

  • userName
  • profile.internalSystemID
  • ser.emails).value <--- this is a wrong key

During a subsequent phase when bindings are invoked, since invocation logic isn't able to find the binding using key "emails.value" (which is how the HTTP request parameter is expected to be named) in pathSpec, it uses the default binding which is obviously different from what we wanted.

Unfortunately it's a private static method, so we can override anything on our end. Also, we could have worked around it by trying to also register an alias with this binding but none of the binder methods exposed take alias an argument and hence when they internally construct AliasingPathBinder, the alias is always null.


No further details from DATACMNS-1302

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.