/** * OnDuplicateKey not returning correct number */ package testsuite.simple; import testsuite.BaseTestCase; /** * @author Tonci * */ public class TestBug39352 extends BaseTestCase { public TestBug39352(String name) { super(name); // TODO Auto-generated constructor stub } public void testBug39352() throws Exception { System.out.println("java.vm.version : " + System.getProperty("java.vm.version")); System.out.println("java.vm.vendor : " + System.getProperty("java.vm.vendor")); System.out.println("java.runtime.version : " + System.getProperty("java.runtime.version")); System.out.println("os.name : " + System.getProperty("os.name")); System.out.println("os.version : " + System.getProperty("os.version ")); System.out.println("sun.management.compiler : " + System.getProperty("sun.management.compiler")); try { createTable("bug39352", "(id INT PRIMARY KEY, data VARCHAR(100))"); assertEquals(1, this.stmt.executeUpdate("INSERT INTO bug39352 (id,data) values (1,'a')")); int rowsAffected = this.stmt.executeUpdate("INSERT INTO bug39352 (id, data) VALUES(2, 'bb') " + "ON DUPLICATE KEY " + "UPDATE data=values(data)"); assertEquals("First UPD failed", 1, rowsAffected); rowsAffected = this.stmt.executeUpdate("INSERT INTO bug39352 (id, data) VALUES(2, 'bbb') " + "ON DUPLICATE KEY " + "UPDATE data=values(data)"); assertEquals("2nd UPD failed", 2, rowsAffected); rowsAffected = this.stmt.executeUpdate("INSERT INTO bug39352 (id, data) VALUES(2, 'bbb') " + "ON DUPLICATE KEY " + "UPDATE data=values(data)"); assertEquals("3rd UPD failed", 0, rowsAffected); } finally { closeMemberJDBCResources(); } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub junit.textui.TestRunner.run(TestBug39352.class); } }