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:
Christoph Strobl
2022-03-10 14:30:08 +01:00
committed by Mark Paluch
parent 7dd2f350eb
commit 7bcf0322d2

View File

@@ -2300,6 +2300,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;