-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix: fix executeBatch can not get targetSql in Statement mode #2575
Conversation
@Override | ||
public void addBatch(String sql) throws SQLException { | ||
if (StringUtils.isNotBlank(targetSQL)) { | ||
targetSQL += "; " + sql; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the business sql has ";", the spliced sql will be wrong.
But the business side can handle it, and it can be changed here or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be problems using split characters here. The best strategy is to store sql in List
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be problems using split characters here. The best strategy is to store sql in List
Released soon, no major changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
test batchUpdate(sql1,sql2,sql3) well, unsupport batchUpdate(sql1;sql2;sql3).
Test case failed, because "targetSQL = null;", but I think you are right to add it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the unit test at io.seata.rm.datasource.StatementProxyTest#testGetTargetSQL
I will fix it now
----- 原始邮件 -----
发件人:will <notifications@github.com>
收件人:seata/seata <seata@noreply.github.com>
抄送人:HankDevelop <kuliuht@sina.com>, Author <author@noreply.github.com>
主题:Re: [seata/seata] fix bug#2537 jdbcTemplate batchUpdate can not get targetSql (#2575)
日期:2020年04月19日 21点13分
@l81893521 commented on this pull request.
Please fix the unit test at io.seata.rm.datasource.StatementProxyTest#testGetTargetSQL
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@HankDevelop Thanks. We will test it later. |
Codecov Report
@@ Coverage Diff @@
## develop #2575 +/- ##
=============================================
- Coverage 51.19% 51.18% -0.02%
+ Complexity 2806 2804 -2
=============================================
Files 554 554
Lines 17768 17774 +6
Branches 2101 2101
=============================================
Hits 9097 9097
- Misses 7814 7817 +3
- Partials 857 860 +3
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test passed.
jdbcTemplate.update("update seata.`account_tbl` set money = money - ? where user_id = ?;update seata.`account_tbl` set money = money - ? where user_id = ?;",
new Object[] {money, userIds[0], money, userIds[1]});
jdbcTemplate.batchUpdate(
"update account_tbl set money = money - " + money + ", sex = 1 where user_id = \"" + userIds[0] + "\"",
"update account_tbl set money = money - " + money + ", sex = 1 where user_id = \"" + userIds[1] + "\"");
jdbcTemplate.batchUpdate("update account_tbl set money = money - ?, sex = 1 where user_id = ?", new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
String userId = userIds[i];
ps.setInt(1, money);
ps.setString(2, userId);
}
@Override
public int getBatchSize() {
return userIds.length;
}
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please wait @slievrly review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, #2575 (comment)
Ⅰ. Describe what this PR did
Ⅱ. Does this pull request fix one issue?
fix bug #2537
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews
in seata 1.1.0 addBatch could invoke only once。
if use jdbcTemplate.batchUpdate(String...sql), Only supports one SQL