Closed mp911de closed 5 years ago
Invoking a RowCountOperation operation and applying an extractor function results in a ClassCastException. The extractor function is not applied.
RowCountOperation
ClassCastException
Reproducible via CREATE TABLE foo (id INT) and INSERT INTO foo (id) values(42) to trigger the insert statement.
CREATE TABLE foo (id INT)
INSERT INTO foo (id) values(42)
Postgres version: PostgreSQL 10.4 on x86_64-apple-darwin14.5.0, compiled by Apple LLVM version 7.0.0 (clang-700.1.76), 64-bit
Reproducer:
private DataSource dataSource() { return DataSourceFactory.newFactory("org.postgresql.adba.PgDataSourceFactory") .builder() .url("jdbc:postgresql://localhost:5432/postgres") .username("postgres") .password("") .build(); } @Test public void shouldCount() { DataSource ds = dataSource(); CompletableFuture<Long> t; try (Session session = ds.getSession()) { // Create table beforehand with: CREATE TABLE foo (id INT); Submission<Long> count = session .<Long>rowCountOperation("INSERT INTO foo (id) values(42)") .apply(Result.RowCount::getCount) .submit(); t = count.getCompletionStage().toCompletableFuture(); } t.join(); assertThat(t.join()).isEqualTo(1L); ds.close(); }
java.lang.ClassCastException: class org.postgresql.adba.util.PgCount cannot be cast to class java.lang.Long (org.postgresql.adba.util.PgCount is in unnamed module of loader 'app'; java.lang.Long is in module java.base of loader 'bootstrap')
Invoking a
RowCountOperation
operation and applying an extractor function results in aClassCastException
. The extractor function is not applied.Reproducible via
CREATE TABLE foo (id INT)
andINSERT INTO foo (id) values(42)
to trigger the insert statement.Postgres version: PostgreSQL 10.4 on x86_64-apple-darwin14.5.0, compiled by Apple LLVM version 7.0.0 (clang-700.1.76), 64-bit
Reproducer: