simple fix for colon use in SQL select statement

This commit is contained in:
Jörg Prante 2022-03-08 18:45:27 +01:00
parent d35071b910
commit 81a0bd8bc9

View file

@ -65,19 +65,21 @@ public class MixedParameterSql {
} }
newSql.append(sql, searchIndex, nextColonIndex); newSql.append(sql, searchIndex, nextColonIndex);
String paramName = sql.substring(nextColonIndex + 1, endOfNameIndex); String paramName = sql.substring(nextColonIndex + 1, endOfNameIndex);
boolean secretParam = paramName.startsWith("secret"); if (!"".equals(paramName)) {
Object arg = nameToArg.get(paramName); boolean secretParam = paramName.startsWith("secret");
if (arg instanceof RewriteArg) { Object arg = nameToArg.get(paramName);
newSql.append(((RewriteArg) arg).getSql()); if (arg instanceof RewriteArg) {
rewrittenArgs.add(paramName); newSql.append(((RewriteArg) arg).getSql());
} else { rewrittenArgs.add(paramName);
newSql.append('?');
if (nameToArg.containsKey(paramName)) {
argsList.add(secretParam ? new SecretArg(arg) : arg);
} else { } else {
throw new DatabaseException("The SQL requires parameter ':" + paramName + "' but no value was provided"); newSql.append('?');
if (nameToArg.containsKey(paramName)) {
argsList.add(secretParam ? new SecretArg(arg) : arg);
} else {
throw new DatabaseException("The SQL requires parameter ':" + paramName + "' but no value was provided");
}
argNamesList.add(paramName);
} }
argNamesList.add(paramName);
} }
searchIndex = endOfNameIndex; searchIndex = endOfNameIndex;
} else { } else {