提交 577ae0bb 编写于 作者: G gaoht

fix #124...

fix #124 com.dangdang.ddframe.rdb.sharding.jdbc.adapter.AbstractStatementAdapter.getUpdateCount error
上级 e5425835
......@@ -123,9 +123,12 @@ public abstract class AbstractStatementAdapter extends AbstractUnsupportedOperat
public final int getUpdateCount() throws SQLException {
int result = 0;
for (Statement each : getRoutedStatements()) {
if (each.getUpdateCount() == -1) {
continue;
}
result += each.getUpdateCount();
}
return result;
return (result < 1) ? -1 : result;
}
@Override
......@@ -211,7 +214,7 @@ public abstract class AbstractStatementAdapter extends AbstractUnsupportedOperat
* 获取路由的静态语句对象集合.
*
* @return 路由的静态语句对象集合
* @throws SQLException
* @throws SQLException SQL执行异常
*/
protected abstract Collection<? extends Statement> getRoutedStatements() throws SQLException;
}
......@@ -128,6 +128,18 @@ public final class StatementAdapterTest extends AbstractShardingDataBasesOnlyDBU
assertThat(actual.getUpdateCount(), is(40));
}
@Test
public void assertGetUpdateCountNoData() throws SQLException {
actual.execute("DELETE FROM `t_order` WHERE `status` = 'none'");
assertThat(actual.getUpdateCount(), is(-1));
}
@Test
public void assertGetUpdateCountSelect() throws SQLException {
actual.execute("SELECT * FROM `t_order`");
assertThat(actual.getUpdateCount(), is(-1));
}
@Test
public void assertGetWarnings() throws SQLException {
assertNull(actual.getWarnings());
......
......@@ -17,6 +17,7 @@ weight = 1
1. [ISSUE #36](https://github.com/dangdangdotcom/sharding-jdbc/issues/36) ShardingPreparedStatement无法反复设置参数
1. [ISSUE #114](https://github.com/dangdangdotcom/sharding-jdbc/issues/114) ShardingPreparedStatement执行批处理任务时,反复解析sql导致oom
1. [ISSUE #33](https://github.com/dangdangdotcom/sharding-jdbc/issues/33) Limit支持问题
1. [ISSUE #124](https://github.com/dangdangdotcom/sharding-jdbc/issues/124) com.dangdang.ddframe.rdb.sharding.jdbc.adapter.AbstractStatementAdapter.getUpdateCount返回值不符合JDBC规范
## 1.3.1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册