summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops/write_ops_exec.cpp
diff options
context:
space:
mode:
authorDavid Percy <david.percy@mongodb.com>2022-03-30 19:40:38 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-04-04 17:02:21 +0000
commit7ecd542de5c542c27856032c219a06900778ea3a (patch)
tree5cd411ef82947cb86b07d617d5fde631817ccdd5 /src/mongo/db/ops/write_ops_exec.cpp
parent797daddf5dac8aa111f488d4102e1b88d49e56e3 (diff)
downloadmongo-7ecd542de5c542c27856032c219a06900778ea3a.tar.gz
SERVER-63902 Fix $natural hint on time-series collections
Diffstat (limited to 'src/mongo/db/ops/write_ops_exec.cpp')
-rw-r--r--src/mongo/db/ops/write_ops_exec.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp
index b0b23e3e42b..d1afdc8dde9 100644
--- a/src/mongo/db/ops/write_ops_exec.cpp
+++ b/src/mongo/db/ops/write_ops_exec.cpp
@@ -809,10 +809,8 @@ static SingleWriteResult performSingleUpdateOp(OperationContext* opCtx,
"Cannot perform an upsert on a time-series collection",
!updateRequest->isUpsert());
- // Only translate the hint (if there is one) if it is specified with an index specification
- // document.
- if (!updateRequest->getHint().isEmpty() &&
- updateRequest->getHint().firstElement().fieldNameStringData() != "$hint"_sd) {
+ // Only translate the hint if it is specified with an index key.
+ if (timeseries::isHintIndexKey(updateRequest->getHint())) {
updateRequest->setHint(
uassertStatusOK(timeseries::createBucketsIndexSpecFromTimeseriesIndexSpec(
*timeseriesOptions, updateRequest->getHint())));
@@ -1144,10 +1142,8 @@ static SingleWriteResult performSingleDeleteOp(OperationContext* opCtx,
"Time-series buckets collection is missing time-series options",
timeseriesOptions);
- // Only translate the hint if it is specified by index spec.
- if (!request.getHint().isEmpty() &&
- (request.getHint().firstElement().fieldNameStringData() != "$hint"_sd ||
- request.getHint().firstElement().type() != BSONType::String)) {
+ // Only translate the hint if it is specified by index key.
+ if (timeseries::isHintIndexKey(request.getHint())) {
request.setHint(
uassertStatusOK(timeseries::createBucketsIndexSpecFromTimeseriesIndexSpec(
*timeseriesOptions, request.getHint())));