NamedParameterUtils.parseSqlStatement should parse :{x} style parameter correctly
In my opinion, we should parse ":{x}" style parameter as "x" is parameter using "NamedParameterUtils.parseSqlStatement",
so the condition "j - i > 2" is the correct condition, not "j - i > 3", because if "i" is the index of
":" in ":{x}", and "j" is the index of "}" in ":{x}", "j - i == 3" is true.
Also add a test case for SPR-16663.
This commit is contained in:
committed by
Juergen Hoeller
parent
f4813f5b4c
commit
82cb5dbf2b
@@ -130,7 +130,7 @@ public abstract class NamedParameterUtils {
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
"Non-terminated named parameter declaration at position " + i + " in statement: " + sql);
|
||||
}
|
||||
if (j - i > 3) {
|
||||
if (j - i > 2) {
|
||||
parameter = sql.substring(i + 2, j);
|
||||
namedParameterCount = addNewNamedParameter(namedParameters, namedParameterCount, parameter);
|
||||
totalParameterCount = addNamedParameter(parameterList, totalParameterCount, escapes, i, j + 1, parameter);
|
||||
|
||||
Reference in New Issue
Block a user