DATAMONGO-369 - Fixed query mapping when a DBObject is included in the query object.
Replaced premature return with continue to break the for loop appropriately.
This commit is contained in:
@@ -100,7 +100,7 @@ public class QueryMapper {
|
||||
value = convertId(value);
|
||||
} else if (value instanceof DBObject) {
|
||||
newDbo.put(newKey, getMappedObject((DBObject) value, entity));
|
||||
return newDbo;
|
||||
continue;
|
||||
}
|
||||
|
||||
newDbo.put(newKey, converter.convertToMongoType(value));
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.core.Person;
|
||||
import org.springframework.data.mongodb.core.QueryMapper;
|
||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
||||
@@ -172,14 +173,28 @@ public class QueryMapperUnitTests {
|
||||
mapper.getMappedObject(query, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAMONGO-369
|
||||
*/
|
||||
@Test
|
||||
public void handlesAllPropertiesIfDBObject() {
|
||||
|
||||
DBObject query = new BasicDBObject();
|
||||
query.put("foo", new BasicDBObject("$in", Arrays.asList(1, 2)));
|
||||
query.put("bar", new Person());
|
||||
|
||||
DBObject result = mapper.getMappedObject(query, null);
|
||||
assertThat(result.get("bar"), is(notNullValue()));
|
||||
}
|
||||
|
||||
class Sample {
|
||||
|
||||
|
||||
@Id
|
||||
private String foo;
|
||||
}
|
||||
|
||||
|
||||
class BigIntegerId {
|
||||
|
||||
|
||||
@Id
|
||||
private BigInteger id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user