Skip to content

Commit

Permalink
Add test case for upsert insertId 0 fix
Browse files Browse the repository at this point in the history
Signed-off-by: Leo Xuzhang Lin <[email protected]>
  • Loading branch information
Leo Xuzhang Lin committed Aug 15, 2018
1 parent 125c9fe commit b195f30
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions java/jdbc/src/test/java/io/vitess/jdbc/VitessStatementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -742,5 +742,15 @@ private void testExecute(int fetchSize, boolean simpleExecute, boolean shouldRun
Assert.assertEquals(i, 0); // we should only have one
i++;
}

VitessStatement noUpdate = new VitessStatement(mockConn);
PowerMockito.when(mockCursor.getInsertId()).thenReturn(0L);
PowerMockito.when(mockCursor.getRowsAffected()).thenReturn(1L);

noUpdate.addBatch(sqlUpsert);
noUpdate.executeBatch();

ResultSet empty = noUpdate.getGeneratedKeys();
Assert.assertFalse(empty.next());
}
}

0 comments on commit b195f30

Please sign in to comment.