Implement totalChanges

This commit is contained in:
김선우
2025-03-03 14:33:02 +09:00
parent 6b223421ae
commit f8052a9860
4 changed files with 62 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
package tech.turso.jdbc4;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import java.sql.ResultSet;
@@ -70,4 +71,30 @@ class JDBC4StatementTest {
stmt.close();
assertThrows(SQLException.class, () -> stmt.execute("SELECT 1;"));
}
@Test
void execute_update_should_return_number_of_inserted_elements() throws Exception {
assertThat(stmt.executeUpdate("CREATE TABLE s1 (c1);")).isEqualTo(0);
assertThat(stmt.executeUpdate("INSERT INTO s1 VALUES (0);")).isEqualTo(1);
assertThat(stmt.executeUpdate("INSERT INTO s1 VALUES (1), (2);")).isEqualTo(2);
assertThat(stmt.executeUpdate("INSERT INTO s1 VALUES (3), (4), (5);")).isEqualTo(3);
}
@Test
@Disabled("Limbo update not yet supported")
void execute_update_should_return_number_of_updated_elements() throws Exception {
assertThat(stmt.executeUpdate("CREATE TABLE s1 (c1);")).isEqualTo(0);
assertThat(stmt.executeUpdate("INSERT INTO s1 VALUES (1), (2), (3);")).isEqualTo(3);
assertThat(stmt.executeUpdate("UPDATE s1 SET c1 = 0;")).isEqualTo(3);
}
@Test
@Disabled("Limbo delete has a bug")
void execute_update_should_return_number_of_deleted_elements() throws Exception {
assertThat(stmt.executeUpdate("CREATE TABLE s1 (c1);")).isEqualTo(0);
assertThat(stmt.executeUpdate("INSERT INTO s1 VALUES (1), (2), (3);")).isEqualTo(3);
assertThat(stmt.executeUpdate("DELETE FROM s1")).isEqualTo(3);
}
}