Skip to content

Commit

Permalink
fix npe of sql check
Browse files Browse the repository at this point in the history
  • Loading branch information
yhilmare committed Sep 29, 2024
1 parent feb6a85 commit 71ba96b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public List<CheckViolation> check(@NonNull Statement statement, @NonNull SqlChec
violations.addAll(dropPartition(statement, action));
violations.addAll(truncatePartition(statement, action));
return violations.stream();
}).collect(Collectors.toList());
}).filter(Objects::nonNull).collect(Collectors.toList());
} else if (statement instanceof TruncateTable) {
return Collections.singletonList(SqlCheckUtil.buildViolation(statement.getText(),
statement, getType(), new Object[] {"TRUNCATE TABLE"}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import org.springframework.jdbc.core.JdbcOperations;
Expand Down Expand Up @@ -72,7 +73,7 @@ public List<CheckViolation> check(@NonNull Statement statement, @NonNull SqlChec
violations.addAll(dropPartition(statement, action));
violations.addAll(truncatePartition(statement, action));
return violations.stream();
}).collect(Collectors.toList());
}).filter(Objects::nonNull).collect(Collectors.toList());
} else if (statement instanceof TruncateTable) {
return Collections.singletonList(SqlCheckUtil.buildViolation(statement.getText(),
statement, getType(), new Object[] {"TRUNCATE TABLE"}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,9 @@ public void check_offlineDdl_violationGenerated() {
"create table abcd(id varchar(64))",
"alter table abcd modify id int AUTO_INCREMENT",
"alter table abcd modify id varchar(64)",
"alter table abcd add column a int after a"
"alter table abcd add column a int after a",
"ALTER TABLE `xes_qiwei_teacher_relation` CHANGE `bind_time` "
+ "`bind_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '绑定时间'"
};
JdbcTemplate jdbcTemplate = Mockito.mock(JdbcTemplate.class);
Mockito.when(jdbcTemplate.queryForObject(Mockito.anyString(), Mockito.any(RowMapper.class)))
Expand Down

0 comments on commit 71ba96b

Please sign in to comment.