Skip to content

Commit

Permalink
add support for findByExists, findByIsNotNull
Browse files Browse the repository at this point in the history
  • Loading branch information
agrgr committed Jul 4, 2023
1 parent c668f6f commit e589cc2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,16 @@ public Filter sIndexFilter(Map<String, Object> qualifierMap) {
return Filter.range(getField(qualifierMap), IndexCollectionType.LIST, Long.MIN_VALUE,
getValue1(qualifierMap).toLong());
}
}, EXISTS {
@Override
public Exp filterExp(Map<String, Object> qualifierMap) {
return Exp.binExists(getField(qualifierMap));
}

@Override
public Filter sIndexFilter(Map<String, Object> qualifierMap) {
return null;
}
};

private static Exp getConvertedValue1Exp(Map<String, Object> qualifierMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ private AerospikeCriteria create(Part part, AerospikePersistentProperty property
case NOT_IN -> getCriteria(part, property, v1, null, parameters, FilterOperation.NOT_IN);
case TRUE -> getCriteria(part, property, true, null, parameters, FilterOperation.EQ);
case FALSE -> getCriteria(part, property, false, null, parameters, FilterOperation.EQ);
case EXISTS -> getCriteria(part, property, false, null, parameters, FilterOperation.EXISTS);
case IS_NOT_NULL -> getCriteria(part, property, false, null, parameters, FilterOperation.EXISTS);
default -> throw new IllegalArgumentException("Unsupported keyword '" + part.getType() + "'");
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,18 @@ void findByMapKeyValueNotEqual() {
assertThat(persons).containsOnly(carter);
}

@Test
void findByAddressExists() {
assertThat(stefan.getAddress()).isNull();

List<Person> persons = repository.findByAddressExists();
assertThat(persons).contains(carter);
List<Person> persons2 = repository.findByAddressIsNotNull();
assertThat(persons2).contains(carter);
// List<Person> persons = repository.findByAddressNotExists();
// assertThat(persons).contains(stefan);
}

@Test
void findByMapOfListsKeyValueNotEqual() {
Map<String, List<Integer>> mapOfLists1 = Map.of("0", List.of(100), "1", List.of(200));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ public interface PersonRepository<P extends Person> extends AerospikeRepository<
*/
List<P> findByAddressIsNot(Address address);

List<P> findByAddressExists();

List<P> findByAddressIsNotNull();

List<P> findByAddressNotExists();

List<P> findByAddressIsNull();

/**
* Find all entities that satisfy the condition "have Address with fewer elements or with a corresponding key-value
* lower in ordering than in the given argument" (find by POJO).
Expand Down

0 comments on commit e589cc2

Please sign in to comment.