DATAMONGO-512 - Fixed broken handling of AND in query methods.
Apparently the fix fof DATAMONGO-469 was messed up later on.
This commit is contained in:
@@ -117,8 +117,11 @@ class MongoQueryCreator extends AbstractQueryCreator<Query, Criteria> {
|
||||
}
|
||||
|
||||
PersistentPropertyPath<MongoPersistentProperty> path = context.getPersistentPropertyPath(part.getProperty());
|
||||
return from(part.getType(), where(path.toDotPath(MongoPersistentProperty.PropertyToFieldNameConverter.INSTANCE)),
|
||||
(PotentiallyConvertingIterator) iterator);
|
||||
|
||||
return new Criteria().andOperator(
|
||||
base,
|
||||
from(part.getType(), where(path.toDotPath(MongoPersistentProperty.PropertyToFieldNameConverter.INSTANCE)),
|
||||
(PotentiallyConvertingIterator) iterator));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -265,4 +268,4 @@ class MongoQueryCreator extends AbstractQueryCreator<Query, Criteria> {
|
||||
|
||||
return source.replaceAll("\\*", ".*");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,4 +432,21 @@ public abstract class AbstractPersonRepositoryIntegrationTests {
|
||||
List<Person> result = repository.findByCreatedAtLessThanManually(boyd.createdAt);
|
||||
assertThat(result.isEmpty(), is(false));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAMONGO-521
|
||||
*/
|
||||
@Test
|
||||
public void executesAndQueryCorrectly() {
|
||||
|
||||
List<Person> result = repository.findByFirstnameAndLastname("Dave", "Matthews");
|
||||
|
||||
assertThat(result, hasSize(1));
|
||||
assertThat(result, hasItem(dave));
|
||||
|
||||
result = repository.findByFirstnameAndLastname("Oliver August", "Matthews");
|
||||
|
||||
assertThat(result, hasSize(1));
|
||||
assertThat(result, hasItem(oliver));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,8 @@ public interface PersonRepository extends MongoRepository<Person, String>, Query
|
||||
*/
|
||||
List<Person> findByFirstnameNotIn(Collection<String> firstnames);
|
||||
|
||||
List<Person> findByFirstnameAndLastname(String firstname, String lastname);
|
||||
|
||||
/**
|
||||
* Returns all {@link Person}s with an age between the two given values.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2010-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -97,7 +97,8 @@ public class MongoQueryCreatorUnitTests {
|
||||
getAccessor(converter, "Oliver", person), context);
|
||||
Query query = creator.createQuery();
|
||||
|
||||
assertThat(query, is(query(where("firstName").is("Oliver").and("friend").is(person))));
|
||||
Criteria criteria = new Criteria().andOperator(where("firstName").is("Oliver"), where("friend").is(person));
|
||||
assertThat(query, is(query(criteria)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -222,7 +223,7 @@ public class MongoQueryCreatorUnitTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAMONGO
|
||||
* @see DATAMONGO-413
|
||||
*/
|
||||
@Test
|
||||
public void createsOrQueryCorrectly() {
|
||||
|
||||
Reference in New Issue
Block a user