Skip to content

Commit

Permalink
fix: 修复拼接SQL可能NPE错误
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-hao committed May 31, 2024
1 parent eabe284 commit eaa686a
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public BatchSqlFragments addSql(List<String> sql) {
}

public BatchSqlFragments addSql(String... sql) {
if (sql == null || sql.length == 0) {
return this;
}
if (sql.length == 1) {
return addSql(Collections.singletonList(sql[0]));
}
Expand All @@ -63,11 +66,17 @@ public BatchSqlFragments addParameters(List<Object> parameters) {
@Override
@SuppressWarnings("all")
public BatchSqlFragments addParameter(Collection<?> parameter) {
if (CollectionUtils.isEmpty(parameter)) {
return this;
}
return addParameters(parameter instanceof List ? ((List) parameter) : new ArrayList<>(parameter));
}

@Override
public BatchSqlFragments addParameter(Object... parameter) {
if (parameter == null || parameter.length == 0) {
return this;
}
return addParameters(Arrays.asList(parameter));
}

Expand Down

0 comments on commit eaa686a

Please sign in to comment.