DATAMONGO-1183 - Fix field name mapping in IndexOperations.
We now consider the Field annotation when creating indexes via IndexOperations. Original pull request: #750.
This commit is contained in:
committed by
Mark Paluch
parent
684e24aff5
commit
e06f326de3
@@ -127,7 +127,8 @@ public class DefaultIndexOperations implements IndexOperations {
|
||||
indexOptions = addPartialFilterIfPresent(indexOptions, indexDefinition.getIndexOptions(), entity);
|
||||
indexOptions = addDefaultCollationIfRequired(indexOptions, entity);
|
||||
|
||||
return collection.createIndex(indexDefinition.getIndexKeys(), indexOptions);
|
||||
Document mappedKeys = mapper.getMappedObject(indexDefinition.getIndexKeys(), entity);
|
||||
return collection.createIndex(mappedKeys, indexOptions);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,14 @@ public class DefaultIndexOperationsUnitTests {
|
||||
this.template = new MongoTemplate(factory, converter);
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1183
|
||||
public void indexOperationsMapFieldNameCorrectly() {
|
||||
|
||||
indexOpsFor(Jedi.class).ensureIndex(new Index("name", Direction.DESC));
|
||||
|
||||
verify(collection).createIndex(eq(new Document("firstname", -1)), any());
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1854
|
||||
public void ensureIndexDoesNotSetCollectionIfNoDefaultDefined() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user