Skip to content

Commit

Permalink
Minor refactor in GeneratedKeyContextEngine to avoid IndexOutOfBoundE…
Browse files Browse the repository at this point in the history
…xception (#32936)

* Minor refactor in GeneratedKeyContextEngine to avoid IndexOutOfBoundException

* fix unit test
  • Loading branch information
strongduanmu committed Sep 20, 2024
1 parent 04de462 commit 474c0f3
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ private GeneratedKeyContext findGeneratedKey(final Map<String, Integer> insertCo
if (params.isEmpty()) {
continue;
}
if (null != params.get(((ParameterMarkerExpressionSegment) expression).getParameterMarkerIndex())) {
if (params.size() > ((ParameterMarkerExpressionSegment) expression).getParameterMarkerIndex()
&& null != params.get(((ParameterMarkerExpressionSegment) expression).getParameterMarkerIndex())) {
result.getGeneratedValues().add((Comparable<?>) params.get(((ParameterMarkerExpressionSegment) expression).getParameterMarkerIndex()));
}
} else if (expression instanceof LiteralExpressionSegment) {
Expand Down

0 comments on commit 474c0f3

Please sign in to comment.