Propagate time series options correctly.
This commit fixes an issue when creating a collection via MongoTemplate without passing on type information. In this case potential time series information was lost. Closes #3984 Original pull request: #3990.
This commit is contained in:
committed by
Mark Paluch
parent
8de07fc3ac
commit
2bb8643d1b
@@ -676,7 +676,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
@Nullable CollectionOptions collectionOptions) {
|
||||
|
||||
Assert.notNull(collectionName, "CollectionName must not be null!");
|
||||
return doCreateCollection(collectionName, convertToDocument(collectionOptions));
|
||||
return doCreateCollection(collectionName, convertToDocument(collectionOptions, Object.class));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -2317,6 +2317,18 @@ public class MongoTemplateUnitTests extends MongoOperationsUnitTests {
|
||||
verify(collection).countDocuments(any(Document.class), any());
|
||||
}
|
||||
|
||||
@Test // GH-3984
|
||||
void templatePassesOnTimeSeriesOptionsWhenNoTypeGiven() {
|
||||
|
||||
template.createCollection("time-series-collection", CollectionOptions.timeSeries("time_stamp"));
|
||||
|
||||
ArgumentCaptor<CreateCollectionOptions> options = ArgumentCaptor.forClass(CreateCollectionOptions.class);
|
||||
verify(db).createCollection(any(), options.capture());
|
||||
|
||||
assertThat(options.getValue().getTimeSeriesOptions().toString())
|
||||
.isEqualTo(new com.mongodb.client.model.TimeSeriesOptions("time_stamp").toString());
|
||||
}
|
||||
|
||||
class AutogenerateableId {
|
||||
|
||||
@Id BigInteger id;
|
||||
|
||||
Reference in New Issue
Block a user