You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2021/04/06 11:50:32 UTC

[GitHub] [calcite] vlsi commented on a change in pull request #2373: [CALCITE-3338] Error with executeBatch and preparedStatement when usi…

vlsi commented on a change in pull request #2373:
URL: https://github.com/apache/calcite/pull/2373#discussion_r607779416



##########
File path: core/src/test/java/org/apache/calcite/jdbc/CalciteRemoteDriverTest.java
##########
@@ -880,6 +880,38 @@ public Service create(AvaticaConnection connection) {
     assertThat(updateCount, is(1));
   }
 
+  @Test public void testInsertBatchWithPreparedStatement() throws Exception {
+    final Connection connection = DriverManager.getConnection(
+        "jdbc:avatica:remote:factory="
+            + LocalServiceModifiableFactory.class.getName());
+
+    PreparedStatement pst = connection.prepareStatement(
+        "insert into \"foo\".\"bar\" values (?, ?, ?, ?, ?)");
+    pst.setInt(1, 1);
+    pst.setInt(2, 1);
+    pst.setString(3, "second");
+    pst.setInt(4, 1);
+    pst.setInt(5, 1);
+    pst.addBatch();
+    pst.addBatch();
+
+    int[] updateCounts = pst.executeBatch();
+    assertThat(updateCounts.length, is(2));
+    assertThat(updateCounts[0], is(1));
+    assertThat(updateCounts[1], is(1));
+    ResultSet resultSet = pst.getResultSet();
+    assertThat(resultSet, nullValue());
+
+    // Now empty batch
+    pst.clearBatch();
+    updateCounts = pst.executeBatch();
+    assertThat(updateCounts.length, is(0));
+    resultSet = pst.getResultSet();
+    assertThat(resultSet, nullValue());

Review comment:
       Please use assertions in such a way that failures make it clear what is verified and why.
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org