Skip to content

Commit

Permalink
[#11967] Skip leading space when binding values
Browse files Browse the repository at this point in the history
  • Loading branch information
kojandy committed Jan 22, 2025
1 parent d8163d2 commit d31d099
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ public List<String> parseOutputParameter(String outputParams) {
for (int index = 0; index < outputParams.length(); index++) {
final char ch = outputParams.charAt(index);
if (ch == SEPARATOR) {
if (lookAhead1(outputParams, index) == SEPARATOR) {
int ahead = lookAhead1(outputParams, index);
if (ahead == SEPARATOR) {
params.append(SEPARATOR);
index++;
} else {
if (ahead == ' ') {
index++;
}
result.add(params.toString());
params = new StringBuilder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,13 @@ public void combineBindValue() {

sql = "select * from table a = ? and b=? and c=? and d=?";
expected = "select * from table a = '1' and b='50' and c=' foo ' and d='11'";
bindValues = parameterParser.parseOutputParameter("1,50, foo ,11");
bindValues = parameterParser.parseOutputParameter("1,50, foo ,11");
result = sqlNormalizer.combineBindValues(sql, bindValues);
Assertions.assertEquals(expected, result);

sql = "select * from table a = ? and b=? and c=? and d=?";
expected = "select * from table a = '1' and b='50' and c='foo' and d='11'";
bindValues = parameterParser.parseOutputParameter("1, 50, foo, 11");
result = sqlNormalizer.combineBindValues(sql, bindValues);
Assertions.assertEquals(expected, result);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public void testParseOutputParameter() throws Exception {

assertOutputParameter("");

assertOutputParameter("1, 2, 3", "1", "2", "3");

assertOutputParameter("1 , 2, 3", "1 ", "2", " 3");
}

private void assertOutputParameter(String outputParam, String... params) {
Expand Down

0 comments on commit d31d099

Please sign in to comment.