Skip to content

Commit 7bcf032

Browse files
christophstroblmp911de
authored andcommitted
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.
1 parent 7dd2f35 commit 7bcf032

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateUnitTests.java

+12
Original file line numberDiff line numberDiff line change
@@ -2300,6 +2300,18 @@ void stillUsesCountDocumentsForNonEmptyQueryEvenIfEstimationEnabled() {
23002300
verify(collection).countDocuments(any(Document.class), any());
23012301
}
23022302

2303+
@Test // GH-3984
2304+
void templatePassesOnTimeSeriesOptionsWhenNoTypeGiven() {
2305+
2306+
template.createCollection("time-series-collection", CollectionOptions.timeSeries("time_stamp"));
2307+
2308+
ArgumentCaptor<CreateCollectionOptions> options = ArgumentCaptor.forClass(CreateCollectionOptions.class);
2309+
verify(db).createCollection(any(), options.capture());
2310+
2311+
assertThat(options.getValue().getTimeSeriesOptions().toString())
2312+
.isEqualTo(new com.mongodb.client.model.TimeSeriesOptions("time_stamp").toString());
2313+
}
2314+
23032315
class AutogenerateableId {
23042316

23052317
@Id BigInteger id;

0 commit comments

Comments
 (0)