DATAMONGO-472 - MongoQueryCreator now correctly translates Not keyword.
We're now translating a negating property reference into a ne(…) call instead of a not().is(…).
This commit is contained in:
@@ -228,7 +228,7 @@ class MongoQueryCreator extends AbstractQueryCreator<Query, Criteria> {
|
||||
case SIMPLE_PROPERTY:
|
||||
return criteria.is(parameters.nextConverted(property));
|
||||
case NEGATING_SIMPLE_PROPERTY:
|
||||
return criteria.not().is(parameters.nextConverted(property));
|
||||
return criteria.ne(parameters.nextConverted(property));
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Unsupported keyword!");
|
||||
|
||||
@@ -495,4 +495,15 @@ public abstract class AbstractPersonRepositoryIntegrationTests {
|
||||
List<Person> result = repository.findByCreatedAtLessThanManually(boyd.createdAt);
|
||||
assertThat(result.isEmpty(), is(false));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAMONGO-472
|
||||
*/
|
||||
@Test
|
||||
public void findsPeopleUsingNotPredicate() {
|
||||
|
||||
List<Person> result = repository.findByLastnameNot("Matthews");
|
||||
assertThat(result, not(hasItem(dave)));
|
||||
assertThat(result, hasSize(5));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,4 +183,11 @@ public interface PersonRepository extends MongoRepository<Person, String>, Query
|
||||
*/
|
||||
List<Person> findByCreatedAtAfter(Date date);
|
||||
|
||||
/**
|
||||
* @see DATAMONGO-472
|
||||
* @param lastname
|
||||
* @return
|
||||
*/
|
||||
List<Person> findByLastnameNot(String lastname);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user