Skip to content

Commit 1277a52

Browse files
committed
Let Result.getRowsUpdated() return Long.
[resolves #484] Signed-off-by: Mark Paluch <[email protected]>
1 parent 775b1aa commit 1277a52

12 files changed

+25
-25
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<postgresql.version>42.3.1</postgresql.version>
4848
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4949
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
50-
<r2dbc-spi.version>0.9.0.RELEASE</r2dbc-spi.version>
50+
<r2dbc-spi.version>1.0.0.BUILD-SNAPSHOT</r2dbc-spi.version>
5151
<reactor.version>2020.0.15</reactor.version>
5252
<scram-client.version>2.1</scram-client.version>
5353
<spring-framework.version>5.3.14</spring-framework.version>

src/main/java/io/r2dbc/postgresql/PostgresqlConnection.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ final class PostgresqlConnection implements io.r2dbc.postgresql.api.PostgresqlCo
7171

7272
private final Codecs codecs;
7373

74-
private final Flux<Integer> validationQuery;
74+
private final Flux<Long> validationQuery;
7575

7676
private final AtomicReference<NotificationAdapter> notificationAdapter = new AtomicReference<>();
7777

@@ -380,15 +380,15 @@ public Mono<Boolean> validate(ValidationDepth depth) {
380380
return;
381381
}
382382

383-
this.validationQuery.subscribe(new CoreSubscriber<Integer>() {
383+
this.validationQuery.subscribe(new CoreSubscriber<Long>() {
384384

385385
@Override
386386
public void onSubscribe(Subscription s) {
387387
s.request(Integer.MAX_VALUE);
388388
}
389389

390390
@Override
391-
public void onNext(Integer integer) {
391+
public void onNext(Long integer) {
392392

393393
}
394394

src/main/java/io/r2dbc/postgresql/PostgresqlResult.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ final class PostgresqlResult extends AbstractReferenceCounted implements io.r2db
6161

6262
@Override
6363
@SuppressWarnings({"rawtypes", "unchecked"})
64-
public Mono<Integer> getRowsUpdated() {
64+
public Mono<Long> getRowsUpdated() {
6565

6666
return this.messages
6767
.<Integer>handle((message, sink) -> {
@@ -88,7 +88,7 @@ public Mono<Integer> getRowsUpdated() {
8888
return;
8989
}
9090

91-
int sum = 0;
91+
long sum = 0;
9292

9393
for (Integer integer : list) {
9494
sum += integer;

src/main/java/io/r2dbc/postgresql/PostgresqlSegmentResult.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private PostgresqlSegmentResult(Flux<Segment> segments) {
114114
}
115115

116116
@Override
117-
public Mono<Integer> getRowsUpdated() {
117+
public Mono<Long> getRowsUpdated() {
118118
return this.segments
119119
.<Integer>handle((segment, sink) -> {
120120

@@ -137,7 +137,7 @@ public Mono<Integer> getRowsUpdated() {
137137
return;
138138
}
139139

140-
int sum = 0;
140+
long sum = 0;
141141

142142
for (Integer integer : list) {
143143
sum += integer;

src/main/java/io/r2dbc/postgresql/api/PostgresqlResult.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface PostgresqlResult extends Result {
3333
* {@inheritDoc}
3434
*/
3535
@Override
36-
Mono<Integer> getRowsUpdated();
36+
Mono<Long> getRowsUpdated();
3737

3838
/**
3939
* {@inheritDoc}

src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ private <IN, OUT> void testCodec(Class<IN> javaType, IN value, Class<OUT> outTyp
738738

739739
.concatWith(close(connection)))
740740
.as(StepVerifier::create)
741-
.expectNext(1)
741+
.expectNext(1L)
742742
.verifyComplete();
743743

744744
SERVER.getJdbcOperations().execute("DELETE FROM test");
@@ -754,7 +754,7 @@ private <IN, OUT> void testCodec(Class<IN> javaType, IN value, Class<OUT> outTyp
754754

755755
.concatWith(close(connection)))
756756
.as(StepVerifier::create)
757-
.expectNext(1)
757+
.expectNext(1L)
758758
.verifyComplete();
759759
} else {
760760

@@ -769,7 +769,7 @@ private <IN, OUT> void testCodec(Class<IN> javaType, IN value, Class<OUT> outTyp
769769

770770
.concatWith(close(connection)))
771771
.as(StepVerifier::create)
772-
.expectNext(1)
772+
.expectNext(1L)
773773
.verifyComplete();
774774

775775
SERVER.getJdbcOperations().execute("DELETE FROM test");
@@ -785,7 +785,7 @@ private <IN, OUT> void testCodec(Class<IN> javaType, IN value, Class<OUT> outTyp
785785

786786
.concatWith(close(connection)))
787787
.as(StepVerifier::create)
788-
.expectNext(1)
788+
.expectNext(1L)
789789
.verifyComplete();
790790
}
791791

@@ -856,7 +856,7 @@ private <W, R> void testCodecReadAs(W toWrite, Class<R> javaTypeToRead, Consumer
856856

857857
.concatWith(close(connection)))
858858
.as(StepVerifier::create)
859-
.expectNext(1)
859+
.expectNext(1L)
860860
.verifyComplete();
861861

862862
this.connectionFactory.create()

src/test/java/io/r2dbc/postgresql/PostgresqlResultUnitTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void toResultCommandComplete() {
4343

4444
result.getRowsUpdated()
4545
.as(StepVerifier::create)
46-
.expectNext(1)
46+
.expectNext(1L)
4747
.verifyComplete();
4848
}
4949

@@ -57,7 +57,7 @@ void toResultCommandCompleteUsingSegments() {
5757

5858
result.getRowsUpdated()
5959
.as(StepVerifier::create)
60-
.expectNext(1)
60+
.expectNext(1L)
6161
.verifyComplete();
6262
}
6363

src/test/java/io/r2dbc/postgresql/PostgresqlSegmentResultUnitTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void shouldConsumeRowsUpdated() {
9393

9494
result.getRowsUpdated()
9595
.as(StepVerifier::create)
96-
.expectNext(42)
96+
.expectNext(42L)
9797
.verifyComplete();
9898
}
9999

@@ -105,7 +105,7 @@ void filterShouldRetainUpdateCount() {
105105

106106
result.filter(Result.UpdateCount.class::isInstance).getRowsUpdated()
107107
.as(StepVerifier::create)
108-
.expectNext(42)
108+
.expectNext(42L)
109109
.verifyComplete();
110110
}
111111

src/test/java/io/r2dbc/postgresql/PostgresqlStatementErrorsIntegrationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void shouldReportDataIntegrityViolationUsingSimpleFlow() {
4747

4848
SERVER.getJdbcOperations().execute("CREATE TABLE test (id SERIAL PRIMARY KEY)");
4949

50-
Flux<Integer> insert = Flux.from(this.connection.createStatement("INSERT INTO test (id) VALUES (1) RETURNING *").execute()).flatMap(Result::getRowsUpdated);
50+
Flux<?> insert = Flux.from(this.connection.createStatement("INSERT INTO test (id) VALUES (1) RETURNING *").execute()).flatMap(Result::getRowsUpdated);
5151

5252
insert.thenMany(insert).as(StepVerifier::create).verifyError(R2dbcDataIntegrityViolationException.class);
5353
}
@@ -57,7 +57,7 @@ void shouldReportDataIntegrityViolationUsingExtendedFlow() {
5757

5858
SERVER.getJdbcOperations().execute("CREATE TABLE test (id SERIAL PRIMARY KEY)");
5959

60-
Flux<Integer> insert = Flux.from(this.connection.createStatement("INSERT INTO test (id) VALUES ($1) RETURNING *").bind("$1", 1).execute()).flatMap(Result::getRowsUpdated);
60+
Flux<?> insert = Flux.from(this.connection.createStatement("INSERT INTO test (id) VALUES ($1) RETURNING *").bind("$1", 1).execute()).flatMap(Result::getRowsUpdated);
6161

6262
insert.thenMany(insert).as(StepVerifier::create).verifyError(R2dbcDataIntegrityViolationException.class);
6363
}

src/test/java/io/r2dbc/postgresql/api/MockPostgresqlResult.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static Builder builder() {
4242
}
4343

4444
@Override
45-
public Mono<Integer> getRowsUpdated() {
45+
public Mono<Long> getRowsUpdated() {
4646
return Mono.empty();
4747
}
4848

src/test/java/io/r2dbc/postgresql/codec/EnumCodecIntegrationTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void shouldBindEnumTypeAsString() {
8686
.execute()
8787
.flatMap(PostgresqlResult::getRowsUpdated)
8888
.as(StepVerifier::create)
89-
.expectNext(1)
89+
.expectNext(1L)
9090
.verifyComplete();
9191

9292
String result = SERVER.getJdbcOperations().queryForObject("SELECT the_value FROM enum_test", String.class);
@@ -107,7 +107,7 @@ void shouldBindEnumArrayTypeAsString() {
107107
.execute()
108108
.flatMap(PostgresqlResult::getRowsUpdated)
109109
.as(StepVerifier::create)
110-
.expectNext(1)
110+
.expectNext(1L)
111111
.verifyComplete();
112112

113113
String result = SERVER.getJdbcOperations().queryForObject("SELECT the_value FROM enum_test", String.class);
@@ -125,7 +125,7 @@ void shouldBindEnumArrayType() {
125125
.execute()
126126
.flatMap(PostgresqlResult::getRowsUpdated)
127127
.as(StepVerifier::create)
128-
.expectNext(1)
128+
.expectNext(1L)
129129
.verifyComplete();
130130

131131
this.connection.createStatement("SELECT * FROM enum_test")

src/test/java/io/r2dbc/postgresql/replication/LogicalDecodeIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void shouldReceiveReplication() {
102102

103103
ReplicationStream replicationStream = replicationConnection.startReplication(replicationRequest).block(Duration.ofSeconds(10));
104104

105-
connection.createStatement("INSERT INTO logical_decode_test VALUES('Hello World')").execute().flatMap(PostgresqlResult::getRowsUpdated).as(StepVerifier::create).expectNext(1).verifyComplete();
105+
connection.createStatement("INSERT INTO logical_decode_test VALUES('Hello World')").execute().flatMap(PostgresqlResult::getRowsUpdated).as(StepVerifier::create).expectNext(1L).verifyComplete();
106106

107107
replicationStream.map(byteBuf -> byteBuf.toString(StandardCharsets.UTF_8))
108108
.as(StepVerifier::create)

0 commit comments

Comments
 (0)