summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/pipeline/expression.cpp20
-rw-r--r--src/mongo/db/pipeline/expression_test.cpp41
2 files changed, 2 insertions, 59 deletions
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp
index 5c97ebfc736..ced1cf0f7fc 100644
--- a/src/mongo/db/pipeline/expression.cpp
+++ b/src/mongo/db/pipeline/expression.cpp
@@ -3017,12 +3017,7 @@ Expression::ComputedPaths ExpressionMap::getComputedPaths(const std::string& exp
/* ------------------------- ExpressionMeta ----------------------------- */
-REGISTER_EXPRESSION_CONDITIONALLY(meta,
- ExpressionMeta::parse,
- AllowedWithApiStrict::kConditionally,
- AllowedWithClientType::kAny,
- boost::none,
- true);
+REGISTER_STABLE_EXPRESSION(meta, ExpressionMeta::parse);
namespace {
const std::string textScoreName = "textScore";
@@ -3077,19 +3072,6 @@ intrusive_ptr<Expression> ExpressionMeta::parse(ExpressionContext* const expCtx,
uassert(17307, "$meta only supports string arguments", expr.type() == String);
const auto iter = kMetaNameToMetaType.find(expr.valueStringData());
-
- const auto apiStrict =
- expCtx->opCtx && APIParameters::get(expCtx->opCtx).getAPIStrict().value_or(false);
-
- auto typeName = iter->first;
- auto usesUnstableField = (typeName == "searchScore") || (typeName == "indexKey") ||
- (typeName == "textScore") || (typeName == "searchHighlights");
-
- if (apiStrict && usesUnstableField) {
- uasserted(ErrorCodes::APIStrictError,
- "Provided apiStrict is true with an unstable parameter");
- }
-
if (iter != kMetaNameToMetaType.end()) {
return new ExpressionMeta(expCtx, iter->second);
} else {
diff --git a/src/mongo/db/pipeline/expression_test.cpp b/src/mongo/db/pipeline/expression_test.cpp
index 22fda21d3dc..dc0b2dd7b2e 100644
--- a/src/mongo/db/pipeline/expression_test.cpp
+++ b/src/mongo/db/pipeline/expression_test.cpp
@@ -3046,22 +3046,13 @@ TEST(ExpressionMetaTest, ExpressionMetaSearchScore) {
VariablesParseState vps = expCtx.variablesParseState;
BSONObj expr = fromjson("{$meta: \"searchScore\"}");
auto expressionMeta = ExpressionMeta::parse(&expCtx, expr.firstElement(), vps);
+
MutableDocument doc;
doc.metadata().setSearchScore(1.234);
Value val = expressionMeta->evaluate(doc.freeze(), &expCtx.variables);
ASSERT_EQ(val.getDouble(), 1.234);
}
-TEST(ExpressionMetaTest, ExpressionMetaSearchScoreAPIStrict) {
- auto expCtx = ExpressionContextForTest{};
- APIParameters::get(expCtx.opCtx).setAPIStrict(true);
- VariablesParseState vps = expCtx.variablesParseState;
- BSONObj expr = fromjson("{$meta: \"searchScore\"}");
- ASSERT_THROWS_CODE(ExpressionMeta::parse(&expCtx, expr.firstElement(), vps),
- AssertionException,
- ErrorCodes::APIStrictError);
-}
-
TEST(ExpressionMetaTest, ExpressionMetaSearchHighlights) {
auto expCtx = ExpressionContextForTest{};
VariablesParseState vps = expCtx.variablesParseState;
@@ -3076,16 +3067,6 @@ TEST(ExpressionMetaTest, ExpressionMetaSearchHighlights) {
ASSERT_DOCUMENT_EQ(val.getDocument(), highlights);
}
-TEST(ExpressionMetaTest, ExpressionMetasearchHighlightsAPIStrict) {
- auto expCtx = ExpressionContextForTest{};
- APIParameters::get(expCtx.opCtx).setAPIStrict(true);
- VariablesParseState vps = expCtx.variablesParseState;
- BSONObj expr = fromjson("{$meta: \"searchHighlights\"}");
- ASSERT_THROWS_CODE(ExpressionMeta::parse(&expCtx, expr.firstElement(), vps),
- AssertionException,
- ErrorCodes::APIStrictError);
-}
-
TEST(ExpressionMetaTest, ExpressionMetaGeoNearDistance) {
auto expCtx = ExpressionContextForTest{};
BSONObj expr = fromjson("{$meta: \"geoNearDistance\"}");
@@ -3124,16 +3105,6 @@ TEST(ExpressionMetaTest, ExpressionMetaIndexKey) {
ASSERT_DOCUMENT_EQ(val.getDocument(), Document(ixKey));
}
-TEST(ExpressionMetaTest, ExpressionMetaIndexKeyAPIStrict) {
- auto expCtx = ExpressionContextForTest{};
- APIParameters::get(expCtx.opCtx).setAPIStrict(true);
- VariablesParseState vps = expCtx.variablesParseState;
- BSONObj expr = fromjson("{$meta: \"indexKey\"}");
- ASSERT_THROWS_CODE(ExpressionMeta::parse(&expCtx, expr.firstElement(), vps),
- AssertionException,
- ErrorCodes::APIStrictError);
-}
-
TEST(ExpressionMetaTest, ExpressionMetaRecordId) {
auto expCtx = ExpressionContextForTest{};
BSONObj expr = fromjson("{$meta: \"recordId\"}");
@@ -3183,16 +3154,6 @@ TEST(ExpressionMetaTest, ExpressionMetaTextScore) {
ASSERT_EQ(val.getDouble(), 1.23);
}
-TEST(ExpressionMetaTest, ExpressionMetaTextScoreAPIStrict) {
- auto expCtx = ExpressionContextForTest{};
- APIParameters::get(expCtx.opCtx).setAPIStrict(true);
- VariablesParseState vps = expCtx.variablesParseState;
- BSONObj expr = fromjson("{$meta: \"textScore\"}");
- ASSERT_THROWS_CODE(ExpressionMeta::parse(&expCtx, expr.firstElement(), vps),
- AssertionException,
- ErrorCodes::APIStrictError);
-}
-
TEST(ExpressionMetaTest, ExpressionMetaSearchScoreDetails) {
auto expCtx = ExpressionContextForTest{};
BSONObj expr = fromjson("{$meta: \"searchScoreDetails\"}");