#344 - Polishing.
Consider projection properties as SELECT projection. Refactor distinct() into marker method without accepting a boolean flag. Make distinct field final. Update tests. Original pull request: #346.
This commit is contained in:
@@ -156,6 +156,26 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // gh-344
|
||||
public void shouldFindApplyingDistinctProjection() {
|
||||
|
||||
LegoSet legoSet1 = new LegoSet(null, "SCHAUFELRADBAGGER", 12);
|
||||
LegoSet legoSet2 = new LegoSet(null, "SCHAUFELRADBAGGER", 13);
|
||||
|
||||
repository.saveAll(Arrays.asList(legoSet1, legoSet2)) //
|
||||
.as(StepVerifier::create) //
|
||||
.expectNextCount(2) //
|
||||
.verifyComplete();
|
||||
|
||||
repository.findDistinctBy() //
|
||||
.map(Named::getName) //
|
||||
.collectList() //
|
||||
.as(StepVerifier::create) //
|
||||
.consumeNextWith(actual -> {
|
||||
assertThat(actual).hasSize(1).contains("SCHAUFELRADBAGGER");
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // gh-41
|
||||
public void shouldFindApplyingSimpleTypeProjection() {
|
||||
|
||||
@@ -282,6 +302,8 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
|
||||
Flux<Named> findAsProjection();
|
||||
|
||||
Flux<Named> findDistinctBy();
|
||||
|
||||
Mono<LegoSet> findByManual(int manual);
|
||||
|
||||
Flux<Integer> findAllIds();
|
||||
|
||||
@@ -614,11 +614,10 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
dataAccessStrategy);
|
||||
BindableQuery bindableQuery = r2dbcQuery.createQuery(getAccessor(queryMethod, new Object[] { "John" }));
|
||||
|
||||
assertThat(bindableQuery.get())
|
||||
.isEqualTo("SELECT " + DISTINCT + " " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1");
|
||||
assertThat(bindableQuery.get()).isEqualTo("SELECT " + DISTINCT + " " + TABLE + ".first_name, " + TABLE
|
||||
+ ".foo FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1");
|
||||
}
|
||||
|
||||
|
||||
private R2dbcQueryMethod getQueryMethod(String methodName, Class<?>... parameterTypes) throws Exception {
|
||||
Method method = UserRepository.class.getMethod(methodName, parameterTypes);
|
||||
return new R2dbcQueryMethod(method, new DefaultRepositoryMetadata(UserRepository.class),
|
||||
@@ -696,8 +695,8 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
Flux<User> findTop3ByFirstName(String firstName);
|
||||
|
||||
Mono<User> findFirstByFirstName(String firstName);
|
||||
|
||||
Mono<User> findDistinctByFirstName(String firstName);
|
||||
|
||||
Mono<UserProjection> findDistinctByFirstName(String firstName);
|
||||
|
||||
Mono<Integer> deleteByFirstName(String firstName);
|
||||
}
|
||||
@@ -713,4 +712,11 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
private Integer age;
|
||||
private Boolean active;
|
||||
}
|
||||
|
||||
interface UserProjection {
|
||||
|
||||
String getFirstName();
|
||||
|
||||
String getFoo();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user