Skip to content

Commit 49c0d86

Browse files
Faron Duttonchristophstrobl
Faron Dutton
authored andcommitted
Adds failing unit-test for issue #4839 NPE when projecting to an interface and using StringBasedAggregation
1 parent 31dfa6d commit 49c0d86

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/AbstractPersonRepositoryIntegrationTests.java

+5
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,11 @@ void readsClosedProjection() {
12751275
assertThat(repository.findClosedProjectionBy()).isNotEmpty();
12761276
}
12771277

1278+
@Test // https://github.com/spring-projects/spring-data-mongodb/issues/4839
1279+
void findAggregatedClosedProjectionBy() {
1280+
assertThat(repository.findAggregatedClosedProjectionBy()).isNotEmpty();
1281+
}
1282+
12781283
@Test // DATAMONGO-1865
12791284
void findFirstEntityReturnsFirstResultEvenForNonUniqueMatches() {
12801285
assertThat(repository.findFirstBy()).isNotNull();

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/PersonRepository.java

+4
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ Page<Person> findByCustomQueryLastnameAndAddressStreetInList(String lastname, Li
386386
// DATAMONGO-1752
387387
Iterable<PersonSummary> findClosedProjectionBy();
388388

389+
// https://github.com/spring-projects/spring-data-mongodb/issues/4839
390+
@Aggregation("{ '$project': { _id : 0, firstName : 1, lastname : 1 } }")
391+
Iterable<PersonSummary> findAggregatedClosedProjectionBy();
392+
389393
@Query(sort = "{ age : -1 }")
390394
List<Person> findByAgeGreaterThan(int age);
391395

0 commit comments

Comments
 (0)