Skip to content

Commit

Permalink
Let Result.getRowsUpdated() return Long.
Browse files Browse the repository at this point in the history
This is to allow for large update counts.

[resolves #255]

Signed-off-by: Mark Paluch <[email protected]>
  • Loading branch information
mp911de committed Jan 27, 2022
1 parent fbc8625 commit 03977f5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
7 changes: 7 additions & 0 deletions r2dbc-spec/src/main/asciidoc/changes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

The following section reflects the history of changes.

[[changes.1.0.0]]
== 1.0

Revised `Result.getRowsUpdated()` signature::

* `Result.getRowsUpdated()` now returns a `Long` value instead of `Integer` to allow for large update counts.

[[changes.0.9.x]]
== 0.9

Expand Down
2 changes: 1 addition & 1 deletion r2dbc-spec/src/main/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ifdef::backend-pdf[]
:toc:
endif::[]

(C) 2017-2021 The original authors.
(C) 2017-2022 The original authors.

NOTE: Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.

Expand Down
2 changes: 1 addition & 1 deletion r2dbc-spec/src/main/asciidoc/result.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The following example shows how to get a count of updated rows:
[source,java]
----
// result is a Result object
Publisher<Integer> rowsUpdated = result.getRowsUpdated();
Publisher<Long> rowsUpdated = result.getRowsUpdated();
----
====

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public static MockResult empty() {
}

@Override
public Flux<Integer> getRowsUpdated() {
return this.segments.filter(UpdateCount.class::isInstance).cast(UpdateCount.class).map(UpdateCount::value).collect(Collectors.summingInt(Long::intValue)).flux();
public Flux<Long> getRowsUpdated() {
return this.segments.filter(UpdateCount.class::isInstance).cast(UpdateCount.class).map(UpdateCount::value).collect(Collectors.summingLong(Long::longValue)).flux();
}

@Override
Expand Down
10 changes: 5 additions & 5 deletions r2dbc-spi-test/src/main/java/io/r2dbc/spi/test/TestKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public interface TestKit<T> {
* @param result the result object
* @return mono emitting the update row count.
*/
default Mono<Integer> extractRowsUpdated(Result result) {
default Mono<Long> extractRowsUpdated(Result result) {
return Mono.from(result.getRowsUpdated());
}

Expand Down Expand Up @@ -795,9 +795,9 @@ default void savePoint() {
Connection::close)
.as(StepVerifier::create)
.expectNext(collectionOf(100)).as("test_value from select")
.expectNext(1).as("rows inserted")
.expectNext(1L).as("rows inserted")
.expectNext(collectionOf(100, 200)).as("values from select")
.expectNext(1).as("rows inserted")
.expectNext(1L).as("rows inserted")
.expectNext(collectionOf(100, 200, 300)).as("values from select")
.expectNext(collectionOf(100, 200)).as("values from select")
.verifyComplete();
Expand Down Expand Up @@ -907,7 +907,7 @@ default void transactionCommit() {
Connection::close)
.as(StepVerifier::create)
.expectNext(collectionOf(100)).as("test_value from select")
.expectNext(1).as("rows inserted")
.expectNext(1L).as("rows inserted")
.expectNext(collectionOf(100, 200)).as("values from select")
.expectNext(collectionOf(100, 200)).as("values from select")
.verifyComplete();
Expand Down Expand Up @@ -943,7 +943,7 @@ default void transactionRollback() {
Connection::close)
.as(StepVerifier::create)
.expectNext(collectionOf(100)).as("test_value from select")
.expectNext(1).as("rows inserted")
.expectNext(1L).as("rows inserted")
.expectNext(collectionOf(100, 200)).as("values from select")
.expectNext(collectionOf(100)).as("test_value from select")
.verifyComplete();
Expand Down
2 changes: 1 addition & 1 deletion r2dbc-spi/src/main/java/io/r2dbc/spi/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface Result {
* @return the number of rows updated by a query against a database
* @throws IllegalStateException if the result was consumed
*/
Publisher<Integer> getRowsUpdated();
Publisher<Long> getRowsUpdated();

/**
* Returns a mapping of the rows that are the results of a query against a database. May be empty if the query did not return any rows. A {@link Row} can be only considered valid within a
Expand Down

0 comments on commit 03977f5

Please sign in to comment.