Remove duplicate keys from RedisQueryEngine.

We now avoid duplicate keys if a key is found in two indices.

Closes #2799
This commit is contained in:
Mark Paluch
2023-12-11 10:28:13 +01:00
parent 3ad3874219
commit 5a2a92a221
2 changed files with 67 additions and 27 deletions

View File

@@ -268,6 +268,25 @@ public abstract class RedisRepositoryIntegrationTestBase {
assertThat(repo.findBy(firstPage.nextPageable()).getContent()).hasSize(1);
}
@Test // GH-2799
void shouldReturnEntitiesWithoutDuplicates() {
Person eddard = new Person("eddard", "stark");
eddard.setAlive(true);
Person robb = new Person("robb", "stark");
robb.setAlive(false);
Person jon = new Person("jon", "snow");
jon.setAlive(true);
repo.saveAll(Arrays.asList(eddard, robb, jon));
List<Person> result = repo.findByFirstnameAndLastnameOrAliveIsTrue("eddard", "stark");
assertThat(result).hasSize(2);
assertThat(result).contains(eddard, jon);
}
@Test // DATAREDIS-771
void shouldFindByBooleanIsTrue() {
@@ -537,6 +556,8 @@ public abstract class RedisRepositoryIntegrationTestBase {
List<Person> findByFirstnameOrLastname(String firstname, String lastname);
List<Person> findByFirstnameAndLastnameOrAliveIsTrue(String firstname, String lastname);
List<Person> findFirstBy();
List<Person> findTop2By();