Skip to content

The parameter in Criteria#assertNoBlankInWildcardQuery is set incorrectly #2743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mawen12 opened this issue Oct 18, 2023 · 0 comments
Closed
Labels
type: task A general task

Comments

@mawen12
Copy link
Contributor

mawen12 commented Oct 18, 2023

Criteria#assertNoBlankInWildcardQuery used to check if searchString contains blank.

public Criteria startsWith(String s) {

	Assert.notNull(s, "s may not be null");

        // it should be (s, false, true)
	assertNoBlankInWildcardQuery(s, true, false);
	queryCriteriaEntries.add(new CriteriaEntry(OperationKey.STARTS_WITH, s));
	return this;
}

private void assertNoBlankInWildcardQuery(String searchString, boolean leadingWildcard, boolean trailingWildcard) {

	if (searchString.contains(CRITERIA_VALUE_SEPARATOR)) {
		throw new InvalidDataAccessApiUsageException("Cannot constructQuery '" + (leadingWildcard ? "*" : "") + '"'+ searchString + '"' + (trailingWildcard ? "*" : "") + "'. Use expression or multiple clauses instead.");
	}
}

if call the method startsWith("a c"), it will throw InvalidDataAccessApiUsageException with message Cannot constructQuery '*"a c"'. Use expression or multiple clauses instead.

However, the message should be '"a c"*' to match the startsWith method.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 18, 2023
@sothawo sothawo added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 18, 2023
@sothawo sothawo added this to the 5.2 GA (2023.1.0) milestone Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

No branches or pull requests

3 participants