#235 - Polishing.
Added test and tweaked documentation to clarify that other numeric types beyond `Integer` are admissible. Split a test in order to have meaningful test names. Original pull request: #238.
This commit is contained in:
@@ -142,9 +142,9 @@ Mono<Integer> setFixedFirstnameFor(String firstname, String lastname);
|
||||
|
||||
The result of a modifying query can be:
|
||||
|
||||
* `Void` to discard update count and await completion
|
||||
* `Integer` emitting the affected rows count
|
||||
* `Boolean` to emit whether at least one row was updated
|
||||
* `Void` to discard update count and await completion.
|
||||
* `Integer` or another numeric type emitting the affected rows count.
|
||||
* `Boolean` to emit whether at least one row was updated.
|
||||
|
||||
The `@Modifying` annotation is only relevant in combination with the `@Query` annotation.
|
||||
Derived custom methods do not require this annotation.
|
||||
|
||||
@@ -89,6 +89,14 @@ public class H2R2dbcRepositoryIntegrationTests extends AbstractR2dbcRepositoryIn
|
||||
repository.updateManual(42).as(StepVerifier::create).expectNext(2L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // gh-235
|
||||
public void shouldReturnUpdateCountAsDouble() {
|
||||
|
||||
shouldInsertNewItems();
|
||||
|
||||
repository.updateManualAndReturnDouble(42).as(StepVerifier::create).expectNext(2.0).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // gh-235
|
||||
public void shouldReturnUpdateSuccess() {
|
||||
|
||||
@@ -134,5 +142,9 @@ public class H2R2dbcRepositoryIntegrationTests extends AbstractR2dbcRepositoryIn
|
||||
@Query("UPDATE legoset set manual = :manual")
|
||||
@Modifying
|
||||
Mono<Void> updateManualAndReturnNothing(int manual);
|
||||
|
||||
@Query("UPDATE legoset set manual = :manual")
|
||||
@Modifying
|
||||
Mono<Double> updateManualAndReturnDouble(int manual);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,14 @@ public class R2dbcQueryMethodUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-235
|
||||
public void detectsNotModifyingQuery() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = queryMethod(SampleRepository.class, "differentTable");
|
||||
|
||||
assertThat(queryMethod.isModifyingQuery()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void detectsTableNameFromRepoTypeIfReturnTypeNotAssignable() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = queryMethod(SampleRepository.class, "differentTable");
|
||||
@@ -79,7 +87,6 @@ public class R2dbcQueryMethodUnitTests {
|
||||
|
||||
assertThat(metadata.getJavaType()).isAssignableFrom(Address.class);
|
||||
assertThat(metadata.getTableName()).isEqualTo("contact");
|
||||
assertThat(queryMethod.isModifyingQuery()).isFalse();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
||||
Reference in New Issue
Block a user