提交 4cd4f38d authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix ON DUPLICATE KEY UPDATE for inserts with multiple rows

上级 5d27e1e6
...@@ -439,7 +439,7 @@ public class Insert extends Prepared implements ResultTarget { ...@@ -439,7 +439,7 @@ public class Insert extends Prepared implements ResultTarget {
condition = new ConditionAndOr(ConditionAndOr.AND, condition = new ConditionAndOr(ConditionAndOr.AND,
condition, condition,
new Comparison(session, Comparison.EQUAL, expr, new Comparison(session, Comparison.EQUAL, expr,
list.get(0)[i++])); list.get(getCurrentRowNumber() - 1)[i++]));
} }
} }
} }
......
...@@ -109,12 +109,14 @@ public class TestDuplicateKeyUpdate extends TestBase { ...@@ -109,12 +109,14 @@ public class TestDuplicateKeyUpdate extends TestBase {
assertEquals("UPDATE", rs.getNString(1)); assertEquals("UPDATE", rs.getNString(1));
stat.execute("INSERT INTO table_test2 (a_text, some_text, updatable_text ) " + stat.execute("INSERT INTO table_test2 (a_text, some_text, updatable_text ) " +
"VALUES ('b', 'b', 'test') " + "VALUES ('b', 'b', 'test'), ('c', 'c', 'test2') " +
"ON DUPLICATE KEY UPDATE updatable_text=values(updatable_text)"); "ON DUPLICATE KEY UPDATE updatable_text=values(updatable_text)");
rs = stat.executeQuery("SELECT updatable_text " + rs = stat.executeQuery("SELECT updatable_text " +
"FROM table_test2 where a_text = 'b'"); "FROM table_test2 where a_text in ('b', 'c') order by a_text");
rs.next(); rs.next();
assertEquals("test", rs.getNString(1)); assertEquals("test", rs.getNString(1));
rs.next();
assertEquals("test2", rs.getNString(1));
} }
private void testDuplicateCache(Connection conn) throws SQLException { private void testDuplicateCache(Connection conn) throws SQLException {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论